:root {
  --bg: #081018;
  --surface: rgba(17, 24, 32, 0.92);
  --surface-2: rgba(21, 30, 40, 0.94);
  --surface-3: rgba(26, 38, 50, 0.94);
  --border: #253241;
  --border-soft: rgba(148, 163, 184, 0.18);
  --text: #edf2f7;
  --text-muted: #9aa8b5;
  --text-soft: #c6d0db;
  --accent: #2f80ed;
  --accent-2: #18a058;
  --teal: #14b8a6;
  --rose: #fb7185;
  --violet: #8b5cf6;
  --warning: #f59e0b;
  --danger: #ef4444;
  --unknown: #64748b;
  --topbar-height: 56px;
  --statusbar-height: 30px;
  --gap: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 8%, rgba(20, 184, 166, 0.2), transparent 28%),
    radial-gradient(circle at 86% 18%, rgba(251, 113, 133, 0.16), transparent 24%),
    linear-gradient(135deg, #071018 0%, #0a1018 50%, #090d14 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -30%;
  pointer-events: none;
  background:
    radial-gradient(circle, rgba(47, 128, 237, 0.12) 0 8%, transparent 24%),
    radial-gradient(circle at 70% 40%, rgba(20, 184, 166, 0.1) 0 9%, transparent 24%);
  animation: ambientShift 18s ease-in-out infinite alternate;
}

@keyframes ambientShift {
  from {
    transform: translate3d(-2%, -1%, 0) rotate(0deg);
  }
  to {
    transform: translate3d(3%, 2%, 0) rotate(8deg);
  }
}

button,
input,
select {
  font: inherit;
}

#topbar {
  min-height: var(--topbar-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(13, 19, 26, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-right {
  justify-content: flex-end;
  overflow-x: auto;
  scrollbar-width: thin;
}

.topbar-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  flex: 0 0 auto;
}

.topbar-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.topbar-action {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 6px 11px;
  border: 1px solid rgba(20, 184, 166, 0.45);
  border-radius: 7px;
  background: rgba(20, 184, 166, 0.12);
  color: #d6fff7;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.topbar-action:hover {
  background: rgba(20, 184, 166, 0.22);
}

.topbar-action.danger-action {
  border-color: rgba(251, 113, 133, 0.55);
  background: rgba(239, 68, 68, 0.13);
  color: #ffd9df;
}

.topbar-action.danger-action:hover {
  background: rgba(239, 68, 68, 0.24);
}

.topbar-action.is-off {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.13);
  color: #ffe7ba;
}

.sidebar-toggle {
  display: none;
}

.badge {
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 12px;
}

.badge.online::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent-2);
}

#layout {
  height: calc(100dvh - var(--topbar-height) - var(--statusbar-height));
  padding: var(--gap);
  display: grid;
  grid-template-columns: minmax(260px, 310px) minmax(0, 1fr);
  grid-template-areas: "sidebar center";
  gap: var(--gap);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.card,
.section-card,
#sidebar {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.24);
}

.card {
  padding: 12px;
}

.card h2 {
  margin: 0 0 10px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

#sidebar {
  grid-area: sidebar;
  padding: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-header {
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}

.sidebar-header h2 {
  margin: 0 0 8px;
  color: var(--text-soft);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#device-search,
#pon-rx-filter,
.input-compact {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #0d131a;
  color: var(--text);
  outline: none;
}

select.input-compact {
  cursor: pointer;
}

#device-search {
  font-size: 12px;
}

.device-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.pon-filter-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.scan-button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid rgba(47, 128, 237, 0.58);
  border-radius: 7px;
  background: rgba(47, 128, 237, 0.14);
  color: #dbeafe;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.scan-button:hover {
  background: rgba(47, 128, 237, 0.24);
}

.pon-scan-button {
  border-color: rgba(20, 184, 166, 0.58);
  background: rgba(20, 184, 166, 0.14);
  color: #0f766e;
}

.pon-scan-button:hover {
  background: rgba(20, 184, 166, 0.24);
}

#device-search::placeholder,
#pon-rx-filter::placeholder,
.input-compact::placeholder {
  color: #64748b;
}

#device-search:focus,
#pon-rx-filter:focus,
.input-compact:focus {
  border-color: rgba(47, 128, 237, 0.9);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.14);
}

#device-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.device-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 9px;
  padding: 9px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.device-item:hover,
.device-item.active {
  background: var(--surface-2);
  border-color: rgba(47, 128, 237, 0.55);
}

.device-empty {
  padding: 12px 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.device-icon-wrapper {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #19365c;
}

.device-icon-wrapper.huawei {
  background: #5f1e2b;
}

.device-icon-wrapper.generic {
  background: #2e3650;
}

.device-icon {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.device-main,
.device-title-row {
  min-width: 0;
}

.device-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.device-title-row span:first-child,
.device-sub,
.device-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-sub,
.device-meta {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.ppp-register-badge {
  width: 17px;
  height: 17px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.ppp-register-badge.registered {
  background: #16a34a;
}

.ppp-register-badge.unregistered {
  background: #dc2626;
}

#center-panel {
  grid-area: center;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#device-summary-card {
  width: 100%;
  min-height: 100%;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.empty-state {
  min-height: 100%;
  padding: 28px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(47, 128, 237, 0.14), rgba(20, 184, 166, 0.1)),
    rgba(17, 24, 32, 0.78);
}

.empty-mark {
  width: 72px;
  height: 72px;
  margin-bottom: 14px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  color: white;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 18px 40px rgba(20, 184, 166, 0.18);
  animation: floatGlow 3.5s ease-in-out infinite alternate;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.support-shell {
  display: grid;
  gap: var(--gap);
}

.support-hero,
.support-section,
.section-card {
  padding: 14px;
}

.support-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(135deg, rgba(47, 128, 237, 0.2), rgba(20, 184, 166, 0.12)),
    linear-gradient(135deg, #111820 0%, #172231 100%);
}

.support-hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -80px;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: rgba(251, 113, 133, 0.18);
  filter: blur(4px);
  animation: floatGlow 7s ease-in-out infinite alternate;
}

@keyframes floatGlow {
  from {
    transform: translateY(-6px) scale(0.96);
  }
  to {
    transform: translateY(10px) scale(1.05);
  }
}

.support-eyebrow,
.summary-item-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.support-title {
  margin: 4px 0 3px;
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 800;
  position: relative;
  z-index: 1;
}

.support-title-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.support-subtitle {
  color: var(--text-muted);
  font-size: 13px;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.hero-right {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: end;
  gap: 10px;
}

.support-chip {
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: #0d131a;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.support-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--unknown);
}

.support-chip.on::before {
  background: var(--accent-2);
}

.support-chip.off::before {
  background: var(--danger);
}

.support-chip.unknown::before {
  background: var(--warning);
}

.support-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

.metric-card,
.support-section,
.section-card {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface);
}

.metric-card {
  min-width: 0;
  padding: 12px;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(47, 128, 237, 0.16), transparent 45%);
  opacity: 0.7;
  pointer-events: none;
}

.metric-card:nth-child(2)::before {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), transparent 45%);
}

.metric-card:nth-child(3)::before {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.18), transparent 45%);
}

.metric-card:nth-child(4)::before {
  background: linear-gradient(135deg, rgba(251, 113, 133, 0.14), transparent 45%);
}

.metric-card:hover,
.support-section:hover,
.visual-panel:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.34);
}

.metric-label {
  position: relative;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-value {
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.metric-note {
  position: relative;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11px;
}

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

.support-section {
  min-width: 0;
}

.support-section.primary {
  grid-column: span 7;
}

.support-section.secondary {
  grid-column: span 5;
}

.support-section.full {
  grid-column: span 12;
}

.host-section {
  padding-bottom: 4px;
}

.host-table {
  margin: 0 12px 12px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: rgba(8, 16, 24, 0.42);
}

.host-table-head,
.host-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) minmax(120px, 0.7fr) minmax(140px, 0.8fr) minmax(110px, 0.6fr);
  gap: 8px;
  align-items: center;
}

.host-table-head {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.host-list {
  max-height: 260px;
  overflow: auto;
}

.host-row {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  text-align: left;
}

.host-row:hover {
  background: rgba(47, 128, 237, 0.12);
}

.host-row:last-child {
  border-bottom: 0;
}

.host-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host-row .host-name {
  color: var(--text);
  font-weight: 800;
}

.host-row.muted {
  display: block;
  cursor: default;
}

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

.action-card {
  position: relative;
  overflow: hidden;
}

.action-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  opacity: 0.95;
}

.action-ppp {
  border-color: rgba(245, 158, 11, 0.45);
  background:
    linear-gradient(135deg, rgba(245, 158, 11, 0.16), transparent 44%),
    var(--surface);
}

.action-ppp::before {
  background: linear-gradient(180deg, var(--warning), var(--rose));
}

.action-wifi {
  border-color: rgba(20, 184, 166, 0.42);
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.14), transparent 46%),
    var(--surface);
}

.action-wifi::before {
  background: linear-gradient(180deg, var(--teal), var(--accent));
}

.action-wan {
  border-color: rgba(47, 128, 237, 0.32);
  background:
    linear-gradient(135deg, rgba(47, 128, 237, 0.1), transparent 44%),
    var(--surface);
}

.action-wan::before {
  background: var(--accent);
}

.action-barcode {
  border-color: rgba(20, 184, 166, 0.4);
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.12), transparent 46%),
    var(--surface);
}

.action-barcode::before {
  background: linear-gradient(180deg, var(--teal), var(--accent-2));
}

.action-port-forward {
  border-color: rgba(139, 92, 246, 0.34);
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.12), transparent 44%),
    var(--surface);
}

.action-port-forward::before {
  background: var(--violet);
}

.permission-denied {
  opacity: 0.62;
}

.permission-denied::after {
  content: "Bu islem icin yetki yok";
  position: absolute;
  right: 12px;
  bottom: 10px;
  padding: 4px 8px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.12);
  color: #fecdd3;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-title,
.section-subtitle {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.priority-pill {
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  color: var(--text-soft);
  background: rgba(13, 19, 26, 0.78);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.priority-pill.high {
  border-color: rgba(245, 158, 11, 0.58);
  color: #ffe6b5;
}

.priority-pill.medium {
  border-color: rgba(20, 184, 166, 0.55);
  color: #c9fff7;
}

.wifi-note {
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  background: rgba(13, 19, 26, 0.62);
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.summary-grid,
.form-grid,
.tech-grid {
  display: grid;
  gap: 10px;
}

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

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

.form-grid.port-forward-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.summary-item-value {
  margin-top: 3px;
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.form-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
}

.form-actions.full {
  grid-column: 1 / -1;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid transparent;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.btn-primary {
  background: var(--accent);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text-soft);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #fb7185);
  border-color: rgba(251, 113, 133, 0.62);
  box-shadow: 0 10px 22px rgba(239, 68, 68, 0.2);
}

.btn-primary:hover {
  background: #1f6fda;
}

#subscriber-barcode-save-btn {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  border-color: rgba(34, 197, 94, 0.62);
  box-shadow: 0 10px 22px rgba(34, 197, 94, 0.18);
}

#subscriber-barcode-save-btn:hover {
  filter: brightness(1.06);
}

#subscriber-barcode-scan-btn {
  background: linear-gradient(135deg, #0891b2, #14b8a6);
  border-color: rgba(20, 184, 166, 0.64);
  color: #ecfeff;
  box-shadow: 0 10px 22px rgba(20, 184, 166, 0.16);
}

#subscriber-barcode-scan-btn:hover {
  filter: brightness(1.06);
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-danger:hover {
  filter: brightness(1.06);
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled {
  cursor: wait;
  opacity: 0.65;
}

.network-board {
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.08), rgba(47, 128, 237, 0.08)),
    rgba(17, 24, 32, 0.92);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.board-header {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.board-title {
  margin: 4px 0 0;
  font-size: 17px;
  line-height: 1.2;
}

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

.visual-panel {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  background: rgba(8, 16, 24, 0.72);
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.visual-panel h3 {
  margin: 0 0 10px;
  color: var(--text-soft);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.device-barcode-badge {
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.device-barcode-badge.registered {
  border-color: rgba(20, 184, 166, 0.38);
  background: rgba(20, 184, 166, 0.14);
  color: #a7f3d0;
}

.device-barcode-badge.missing {
  border-color: rgba(239, 68, 68, 0.42);
  background: rgba(239, 68, 68, 0.12);
  color: #fecdd3;
}

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

.barcode-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.barcode-copy-box {
  margin-top: 10px;
  padding: 10px;
  display: grid;
  gap: 6px;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  background: rgba(8, 16, 24, 0.42);
  color: var(--text-soft);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.barcode-match-modal-card {
  width: min(760px, calc(100vw - 24px));
}

.new-device-setup-modal-card {
  width: min(680px, calc(100vw - 24px));
}

.new-device-setup-note {
  margin: 0 0 12px;
  padding: 10px;
  border: 1px solid rgba(20, 184, 166, 0.28);
  border-radius: 7px;
  background: rgba(20, 184, 166, 0.1);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.45;
}

.barcode-match-grid {
  display: grid;
  gap: 9px;
}

.barcode-match-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.barcode-match-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.barcode-match-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  background: rgba(8, 16, 24, 0.44);
}

.barcode-match-item.muted {
  display: block;
  color: var(--text-muted);
}

.barcode-match-info {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.barcode-match-info strong,
.barcode-match-info span,
.barcode-match-info small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.barcode-match-info small {
  color: var(--text-muted);
}

.led-panel {
  grid-column: span 4;
}

.port-panel {
  grid-column: span 8;
}

.fiber-panel {
  grid-column: 1 / -1;
}

.led-bar,
.fiber-grid,
.ports-bar {
  display: grid;
  gap: 8px;
}

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

.led-item {
  min-height: 30px;
  padding: 6px 8px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: #0d131a;
  color: var(--text-soft);
  font-size: 12px;
}

.led-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--unknown);
  flex: 0 0 auto;
}

.led-dot.on {
  background: var(--accent-2);
  box-shadow: 0 0 8px rgba(24, 160, 88, 0.55);
  animation: ledPulse 1.8s ease-in-out infinite;
}

.led-dot.off {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.45);
}

.led-dot.unknown {
  background: var(--unknown);
}

@keyframes ledPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.18);
  }
}

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

.fiber-metric {
  min-width: 0;
  padding: 8px 9px;
  border-radius: 7px;
  background: #0d131a;
  border: 1px solid var(--border);
}

.fiber-metric:nth-child(1) {
  border-color: rgba(24, 160, 88, 0.42);
}

.fiber-metric:nth-child(2) {
  border-color: rgba(20, 184, 166, 0.35);
}

.fiber-metric:nth-child(3) {
  border-color: rgba(47, 128, 237, 0.35);
}

.fiber-metric:nth-child(4) {
  border-color: rgba(245, 158, 11, 0.35);
}

.fiber-metric:nth-child(5) {
  border-color: rgba(139, 92, 246, 0.35);
}

.fiber-metric:nth-child(6) {
  border-color: rgba(251, 113, 133, 0.35);
}

.fiber-label {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fiber-metric strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

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

.port-item {
  min-width: 0;
  min-height: 54px;
  padding: 8px 6px;
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #0d131a;
  color: var(--text-soft);
  font-size: 11px;
}

.port-item small {
  min-height: 12px;
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
}

#status-bar {
  min-height: var(--statusbar-height);
  padding: 0 14px;
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
  background: #0d131a;
  color: var(--text-muted);
  font-size: 11px;
}

[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 7, 12, 0.68);
  backdrop-filter: blur(10px);
}

.modal-card {
  width: min(420px, 100%);
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.11), rgba(47, 128, 237, 0.09)),
    #111820;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.38);
}

.login-backdrop {
  z-index: 50;
}

.login-modal-card {
  width: min(390px, calc(100vw - 24px));
}

.login-status {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--text-soft);
  font-size: 12px;
}

.ppp-modal-card {
  width: min(1060px, 100%);
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
}

.backup-modal-card {
  width: min(560px, 100%);
}

.barcode-modal-card {
  width: min(680px, calc(100vw - 24px));
}

.barcode-scanner {
  position: relative;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #030712;
  aspect-ratio: 16 / 10;
  max-height: min(62dvh, 520px);
}

.barcode-scanner.is-unavailable {
  display: none;
}

.barcode-scanner video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.barcode-frame {
  position: absolute;
  inset: 18% 12%;
  border: 2px solid rgba(34, 211, 238, 0.9);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(3, 7, 18, 0.32);
  pointer-events: none;
}

.barcode-status {
  margin: 10px 0 0;
  color: var(--text-soft);
  font-size: 12px;
}

.barcode-camera-tools {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.barcode-fallback {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

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

.modal-head h2 {
  margin: 4px 0 0;
  font-size: 18px;
}

.icon-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(13, 19, 26, 0.8);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 15px;
  font-weight: 900;
}

.icon-close:hover {
  background: var(--surface-2);
}

.modal-form {
  display: grid;
  gap: 8px;
}

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

.ppp-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(6, auto);
  gap: 10px;
  margin-bottom: 12px;
}

.ppp-select-all {
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(13, 19, 26, 0.78);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.ppp-select-all input,
.ppp-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.ppp-stats {
  margin: -2px 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ppp-stats span {
  min-height: 24px;
  padding: 4px 9px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: rgba(8, 16, 24, 0.44);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
}

.ppp-table-wrap {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: rgba(8, 16, 24, 0.42);
}

.ppp-table-head,
.ppp-row {
  display: grid;
  grid-template-columns: 44px minmax(190px, 1.15fr) minmax(180px, 1fr) minmax(150px, 0.85fr) 178px;
  gap: 8px;
  align-items: center;
}

.ppp-table-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px;
  border-bottom: 1px solid var(--border);
  background: #101821;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ppp-credential-list {
  display: grid;
  gap: 0;
}

.ppp-row {
  min-width: 820px;
  padding: 9px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.ppp-row.needs-update {
  background: rgba(245, 158, 11, 0.08);
}

.ppp-row.unregistered-device {
  background: rgba(47, 128, 237, 0.07);
}

.ppp-row.unregistered-device.is-offline {
  opacity: 0.72;
}

.ppp-row:last-child {
  border-bottom: 0;
}

.ppp-meta {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.ppp-meta strong,
.ppp-device-link,
.ppp-meta span,
.ppp-meta small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ppp-meta strong {
  font-size: 13px;
}

.ppp-device-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: #dbeafe;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 800;
}

.ppp-device-link:hover {
  color: #93c5fd;
  text-decoration: underline;
}

.ppp-meta span {
  color: var(--text-soft);
  font-size: 12px;
}

.ppp-meta small {
  color: var(--text-muted);
  font-size: 11px;
}

.ppp-meta .ppp-alert {
  color: #fbbf24;
  font-weight: 800;
}

.ppp-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.ppp-actions .btn-primary,
.ppp-actions .btn-secondary,
.ppp-actions .btn-danger {
  min-height: 32px;
  padding: 7px 9px;
}

.btn-secondary.is-active,
.topbar-action.is-active {
  border-color: rgba(47, 128, 237, 0.7);
  background: rgba(47, 128, 237, 0.22);
  color: #dbeafe;
}

.status-dot-inline {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.status-dot-inline.on {
  background: #22c55e;
}

.status-dot-inline.off {
  background: #ef4444;
}

.ppp-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.user-list-wrap {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.user-list,
.backup-list {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.user-row,
.backup-row {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 170px);
  gap: 8px;
  align-items: center;
  background: rgba(8, 16, 24, 0.52);
}

.backup-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.backup-meta {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  background: rgba(8, 16, 24, 0.52);
}

.backup-meta strong {
  overflow-wrap: anywhere;
  font-size: 12px;
}

.backup-actions {
  justify-content: space-between;
}

.user-info,
.backup-info {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.user-info strong,
.user-info span,
.backup-info strong,
.backup-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-info strong,
.backup-info strong {
  font-size: 13px;
}

.user-info span,
.backup-info span {
  color: var(--text-muted);
  font-size: 11px;
}

.role-select {
  min-height: 32px;
}

@media (max-width: 1420px) {
  #layout {
    grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
    grid-template-areas: "sidebar center";
  }

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

  .led-panel,
  .port-panel {
    grid-column: span 6;
  }

  .fiber-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
    min-height: 100dvh;
    touch-action: pan-y;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #layout {
    height: auto;
    min-height: calc(100dvh - var(--topbar-height) - var(--statusbar-height));
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "center";
    overflow: visible;
  }

  #sidebar {
    position: fixed;
    top: calc(var(--topbar-height) + 10px);
    bottom: calc(var(--statusbar-height) + 10px);
    left: 10px;
    z-index: 25;
    width: min(360px, calc(100vw - 20px));
    transform: translateX(calc(-100% - 18px));
    transition: transform 0.22s ease;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  body.sidebar-open #sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 24;
    display: block;
    background: rgba(3, 7, 12, 0.48);
    backdrop-filter: blur(4px);
  }

  #center-panel {
    min-height: 0;
    overflow: visible;
  }

  .support-hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-right {
    justify-items: start;
  }

  .status-stack {
    justify-content: flex-start;
  }

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

  .support-section.primary,
  .support-section.secondary {
    grid-column: span 12;
  }

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

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

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

  .led-panel,
  .port-panel {
    grid-column: 1;
  }

  .fiber-panel {
    grid-column: 1;
  }

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

@media (max-width: 900px) {
  #topbar {
    align-items: flex-start;
    padding: 10px 12px;
  }

  .ppp-modal-card {
    width: min(100%, calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
  }

  .ppp-tools {
    grid-template-columns: minmax(0, 1fr);
  }

  .ppp-tools .btn-primary,
  .ppp-tools .btn-secondary {
    width: 100%;
    min-height: 36px;
  }

  .barcode-camera-tools {
    grid-template-columns: minmax(0, 1fr);
  }

  .barcode-modal-card {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
  }

  .barcode-scanner {
    aspect-ratio: 3 / 4;
    max-height: 68dvh;
  }

  .barcode-frame {
    inset: 14% 10%;
  }

  .ppp-select-all {
    justify-content: center;
  }

  .ppp-stats {
    flex-wrap: wrap;
    gap: 6px;
  }

  .ppp-table-wrap {
    overflow-x: hidden;
  }

  .ppp-table-head {
    display: none;
  }

  .ppp-row {
    min-width: 0;
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-areas:
      "select meta"
      "user user"
      "pass pass"
      "actions actions";
    align-items: start;
    gap: 8px;
    padding: 10px;
  }

  .ppp-row > :nth-child(1) {
    grid-area: select;
  }

  .ppp-row > :nth-child(2) {
    grid-area: meta;
  }

  .ppp-row > :nth-child(3) {
    grid-area: user;
  }

  .ppp-row > :nth-child(4) {
    grid-area: pass;
  }

  .ppp-row > :nth-child(5) {
    grid-area: actions;
  }

  .ppp-meta strong,
  .ppp-device-link,
  .ppp-meta span,
  .ppp-meta small {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .ppp-actions {
    justify-content: stretch;
  }

  .ppp-actions button {
    width: 100%;
  }

  #status-bar {
    position: sticky;
    bottom: 0;
    z-index: 9;
  }
}

@media (max-width: 640px) {
  :root {
    --topbar-height: 86px;
    --gap: 10px;
  }

  #topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    gap: 6px;
    padding: 8px 10px;
  }

  .topbar-logo {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    font-size: 12px;
  }

  .topbar-title {
    font-size: 13px;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
  }

  .topbar-right {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .topbar-action {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 5px 9px;
  }

  .badge {
    flex: 0 0 auto;
    justify-content: center;
    min-height: 30px;
    padding: 5px 9px;
  }

  body.sidebar-open #sidebar {
    top: calc(env(safe-area-inset-top, 0px) + 48px);
  }

  body.sidebar-open #topbar {
    min-height: 44px;
    padding: 8px 10px;
  }

  body.sidebar-open .topbar-right {
    display: none;
  }

  .support-title {
    font-size: 20px;
  }

  .support-metrics,
  .summary-grid,
  .tech-grid,
  .form-grid,
  .visual-grid,
  .fiber-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid.port-forward-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .host-table {
    overflow-x: auto;
  }

  .host-table-head,
  .host-row {
    min-width: 620px;
  }

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

  .form-actions,
  .form-actions.full {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .section-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-actions {
    width: 100%;
    justify-content: stretch;
  }

  .btn-primary,
  .btn-secondary,
  .btn-danger {
    width: 100%;
  }

  .user-row,
  .backup-row {
    grid-template-columns: minmax(0, 1fr);
  }
}
