/* VPN Control UI v4 — live render polish.
   Small corrections found during production preview review. */

/* Accessibility */
.skip-link {
  position: fixed !important;
  top: -96px !important;
  left: 14px !important;
  z-index: 2000 !important;
  transform: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 12px !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Technical navigation */
.sidebar-system {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(113, 144, 188, .10);
}
.sidebar-system > summary {
  display: flex;
  min-height: 36px;
  gap: 9px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #607087;
  cursor: pointer;
  font-size: .7rem;
  font-weight: 620;
  list-style: none;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.sidebar-system > summary::-webkit-details-marker { display: none; }
.sidebar-system > summary::after {
  margin-left: auto;
  color: #46556b;
  content: "⌄";
  transition: transform .16s ease;
}
.sidebar-system[open] > summary::after { transform: rotate(180deg); }
.sidebar-system > summary:hover {
  border-color: rgba(112,151,211,.08);
  background: rgba(62,90,135,.07);
  color: #9ba9bb;
}
.sidebar-system-menu {
  display: grid;
  gap: 2px;
  margin: 5px 0 0 8px;
}
.sidebar-system-menu .nav-link {
  min-height: 33px !important;
  opacity: .72;
  font-size: .69rem !important;
}
.sidebar-system-menu .nav-link:hover,
.sidebar-system-menu .nav-link.active { opacity: 1; }

/* Desktop readability */
@media (min-width: 1200px) {
  .sidebar .nav-link { font-size: .82rem !important; }
  .topbar-title { font-size: .92rem !important; }
  .v4-hero-copy { font-size: .86rem; }
  .v4-kpi-label { font-size: .73rem; }
  .v4-kpi-meta { font-size: .7rem; }
  .v4-panel-head h2 { font-size: .92rem; }
  .v4-attention-copy strong { font-size: .78rem; }
  .v4-attention-copy span { font-size: .66rem; }
}

/* Dashboard */
.v4-attention-row[data-count="0"] { display: none; }
.v4-attention-clean { display: flex; }
.v4-attention-list:has(.v4-attention-row:not([data-count="0"])) .v4-attention-clean { display: none; }
.v4-dashboard-grid { align-items: start; }
.v4-attention-panel { align-self: start; }
.v4-attention-panel .v4-attention-list { min-height: 0; }
.v4-attention-panel .v4-empty-state { min-height: 104px; }

@media (min-width: 1200px) {
  .v4-infra-status { padding-top: 14px; padding-bottom: 10px; }
  .v4-infra-orb { width: 64px; height: 64px; flex-basis: 64px; }
  .v4-infra-breakdown {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 14px;
  }
  .v4-infra-breakdown > div { min-height: 31px; }
}

/* Customer list */
.v4-customer-row { transition: background .14s ease, box-shadow .14s ease; }
.v4-customer-row:hover {
  background: linear-gradient(90deg, rgba(53,103,187,.075), rgba(39,55,88,.025)) !important;
  box-shadow: inset 2px 0 0 rgba(76,141,255,.42);
}
.v4-customer-row .v4-customer-name { font-weight: 690 !important; }
.v4-customer-row .v4-customer-email { color: #4f5f75 !important; }
.v4-customer-row .v4-number-cell strong { color: #dce5f1; }
.v4-customer-row.is-muted { opacity: .72; }
.v4-customer-row.is-muted:hover { opacity: .94; }
.v4-customers-page .v4-more-button { opacity: .58; }
.v4-customer-row:hover .v4-more-button,
.v4-more-button[aria-expanded="true"] { opacity: 1; }

/* Customer detail density */
.v4-detail-section-title > a[href*="/devices/"] { display: none !important; }
#customer-overview.v4-detail-panel { padding-top: 12px; padding-bottom: 12px; }
#customer-overview .v4-detail-section-head { margin-bottom: 9px; }
#customer-overview .v4-ready-state { min-height: 54px; padding: 9px 11px; }
#customer-overview .v4-ready-icon {
  width: 29px;
  height: 29px;
  flex-basis: 29px;
  border-radius: 9px;
}
.v4-detail-header .btn-primary { box-shadow: 0 8px 24px rgba(74,119,255,.10); }

/* Device workspace */
.operator-workspace-v4 {
  display: grid;
  gap: 11px;
}
.v4-device-card {
  overflow: visible;
  border: 1px solid rgba(121,149,191,.12);
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(15,24,40,.92), rgba(8,15,27,.92));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.018);
}
.v4-device-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 15px 12px;
  border-bottom: 1px solid rgba(121,149,191,.08);
}
.v4-device-identity { min-width: 0; }
.v4-device-title-line {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
}
.v4-device-title-line h3 {
  margin: 0;
  color: #e7eef8;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.v4-device-meta {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 5px;
  color: #5d6c82;
  font-size: .59rem;
}
.v4-device-meta span + span::before {
  margin-right: 7px;
  color: #344157;
  content: "·";
}
.v4-device-note {
  max-width: 760px;
  margin: 7px 0 0;
  color: #68768b;
  font-size: .61rem;
}
.v4-device-products {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 9px;
}
.v4-device-product-pill {
  display: inline-flex;
  min-height: 23px;
  gap: 5px;
  align-items: center;
  padding: 3px 7px;
  border: 1px solid rgba(116,145,190,.10);
  border-radius: 999px;
  background: rgba(61,81,113,.035);
  color: #536178;
  font-size: .54rem;
  font-weight: 720;
  letter-spacing: .035em;
}
.v4-device-product-pill b {
  color: #65758c;
  font-size: .56rem;
  font-weight: 720;
}
.v4-device-product-pill.is-active {
  border-color: rgba(80,139,255,.19);
  background: rgba(66,119,230,.07);
  color: #83adf1;
}
.v4-device-product-pill.is-active b { color: #a9c7f8; }

.v4-device-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
  align-items: center;
}
.v4-device-actions .btn-sm {
  min-height: 30px;
  padding: 4px 9px !important;
  font-size: .61rem !important;
}
.v4-device-more {
  width: 31px;
  height: 31px;
  border: 1px solid rgba(121,149,191,.12);
  border-radius: 9px;
  background: rgba(12,20,34,.72);
  color: #617087;
  font-size: .68rem;
  letter-spacing: .04em;
}
.v4-device-more:hover,
.v4-device-more[aria-expanded="true"] {
  border-color: rgba(83,137,255,.24);
  color: #bdcadb;
}

.v4-device-settings {
  display: grid;
  gap: 9px;
  padding: 12px 14px 13px;
  border-bottom: 1px solid rgba(121,149,191,.08);
  background: rgba(5,11,20,.28);
}
.v4-device-access-card {
  padding: 13px;
  border: 1px solid rgba(82,140,255,.16);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(17,29,49,.72), rgba(9,17,30,.76));
}
.v4-device-access-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 13px;
}
.v4-device-access-head strong {
  display: block;
  color: #e1e9f4;
  font-size: .72rem;
}
.v4-device-access-head small {
  display: block;
  max-width: 660px;
  margin-top: 4px;
  color: #607087;
  font-size: .59rem;
  line-height: 1.5;
}
.v4-device-access-meta {
  flex: 0 0 auto;
  color: #617087;
  font-size: .58rem;
  text-align: right;
}
.v4-device-access-meta b {
  display: block;
  margin-bottom: 3px;
  color: #cfd9e7;
  font-size: .66rem;
  font-variant-numeric: tabular-nums;
}
.v4-device-access-meta span { display: block; }
.v4-device-access-form {
  display: grid;
  grid-template-columns: minmax(175px,1.15fr) minmax(165px,1fr) minmax(120px,.75fr) 88px 75px 105px;
  gap: 9px;
  align-items: end;
}
.v4-device-access-form .form-label {
  margin-bottom: 5px;
  font-size: .61rem !important;
}
.v4-device-access-form .form-control,
.v4-device-access-form .form-select { min-height: 34px; font-size: .68rem !important; }
.v4-device-access-form .form-text { font-size: .54rem; }
.v4-device-access-footnote {
  margin-top: 9px;
  color: #55647a;
  font-size: .56rem;
}

.v4-device-advanced-card {
  overflow: hidden;
  border: 1px solid rgba(243,185,79,.10);
  border-radius: 10px;
  background: rgba(24,20,19,.30);
}
.v4-device-advanced-card > summary {
  display: flex;
  min-height: 42px;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  color: #6f6b65;
  cursor: pointer;
  list-style: none;
}
.v4-device-advanced-card > summary::-webkit-details-marker { display: none; }
.v4-device-advanced-card > summary > span:first-child { display: flex; flex-direction: column; }
.v4-device-advanced-card > summary strong { color: #928675; font-size: .63rem; }
.v4-device-advanced-card > summary small { margin-top: 2px; color: #5f5b57; font-size: .54rem; }
.v4-device-advanced-card > summary > span:last-child { font-size: .54rem; }
.v4-device-advanced-card[open] { border-color: rgba(243,185,79,.16); }
.v4-device-advanced-body {
  padding: 11px 12px 12px;
  border-top: 1px solid rgba(243,185,79,.08);
}
.v4-device-advanced-body p { margin: 0 0 9px; color: #6f685e; font-size: .58rem; }
.v4-device-move-form { display: grid; grid-template-columns: minmax(220px,1fr) auto; gap: 8px; }

.v4-connection-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 9px;
  padding: 12px 14px 14px;
}
.v4-connection-card {
  min-width: 0;
  padding: 11px;
  border: 1px solid rgba(103,145,215,.16);
  border-radius: 11px;
  background: linear-gradient(155deg, rgba(14,26,44,.82), rgba(7,14,25,.68));
}
.v4-connection-card.is-empty {
  border-color: rgba(112,145,196,.08);
  background: rgba(7,14,24,.38);
  opacity: .58;
}
.v4-connection-card-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 53px;
}
.v4-connection-card-head span {
  display: block;
  margin-bottom: 3px;
  color: #6887b3;
  font-size: .52rem;
  font-weight: 760;
  letter-spacing: .07em;
}
.v4-connection-card-head h4 {
  margin: 0;
  color: #dce5f1;
  font-size: .69rem;
  font-weight: 680;
}
.v4-connection-card-head p {
  margin: 3px 0 0;
  color: #56667d;
  font-size: .54rem;
  line-height: 1.4;
}
.v4-connection-card-head > b {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  place-items: center;
  border: 1px solid rgba(95,133,194,.12);
  border-radius: 7px;
  background: rgba(66,91,132,.07);
  color: #8498b4;
  font-size: .57rem;
}
.v4-connection-item {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(113,145,196,.08);
}
.v4-connection-item-head {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
}
.v4-connection-item-head strong { display: block; color: #e0e7f0; font-size: .62rem; }
.v4-connection-item-head small { display: block; margin-top: 3px; color: #5c6c82; font-size: .53rem; }
.v4-connection-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.v4-connection-actions form { margin: 0; }
.v4-connection-actions .btn-sm { min-height: 27px; padding: 3px 7px !important; font-size: .55rem !important; }
.v4-connection-empty {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  border: 1px dashed rgba(112,145,196,.08);
  border-radius: 9px;
  color: #4c5b70;
  font-size: .55rem;
}
.v4-connection-error {
  margin-top: 7px;
  padding: 6px 7px;
  border-radius: 7px;
  background: rgba(255,101,119,.05);
  color: #b86c77;
  font-size: .53rem;
}

.v4-device-legacy {
  margin: 0 14px 13px;
  border-top: 1px solid rgba(121,149,191,.07);
}
.v4-device-legacy summary {
  padding: 9px 0 0;
  color: #525f72;
  cursor: pointer;
  font-size: .55rem;
}
.v4-device-legacy > div { display: grid; gap: 5px; padding: 8px 0 2px; color: #5b687b; font-size: .55rem; }
.v4-device-legacy a { margin-left: 5px; }

.v4-device-empty-state {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  flex-direction: column;
}
.v4-device-empty-state strong { color: #c8d1df; font-size: .72rem; }
.v4-device-empty-state span { color: #607087; font-size: .61rem; }
.v4-device-empty-state .btn { margin-top: 7px; }

/* Legacy client table */
body:has(.clients-table-wrap) .topbar { border-bottom-color: rgba(243,185,79,.13) !important; }
body:has(.clients-table-wrap) .page-header {
  position: relative;
  padding-top: 34px !important;
}
body:has(.clients-table-wrap) .page-header::before {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid rgba(243,185,79,.16);
  border-radius: 999px;
  background: rgba(243,185,79,.055);
  color: #cba968;
  content: "LEGACY MODE · резервный интерфейс — основной список находится в «Все клиенты»";
  font-size: .58rem;
  font-weight: 670;
  letter-spacing: .025em;
}
body:has(.clients-table-wrap) .sidebar-system-menu .nav-link.active {
  border-color: rgba(243,185,79,.16) !important;
  background: rgba(243,185,79,.045) !important;
  color: #c6ad7a !important;
  box-shadow: inset 2px 0 0 rgba(243,185,79,.5) !important;
}

/* Infrastructure */
.v4-system-page { min-height: calc(100vh - 110px); }
.v4-system-panel { max-width: 100%; }

@media (max-width: 1199.98px) {
  .v4-device-access-form { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .v4-connection-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
  .sidebar-system-menu { margin-left: 0; }
  .v4-device-head { display: block; }
  .v4-device-actions { margin-top: 11px; }
  .v4-device-access-head { display: block; }
  .v4-device-access-meta { margin-top: 8px; text-align: left; }
  .v4-device-access-form { grid-template-columns: 1fr; }
  .v4-device-move-form { grid-template-columns: 1fr; }
  body:has(.clients-table-wrap) .page-header { padding-top: 42px !important; }
  body:has(.clients-table-wrap) .page-header::before {
    max-width: 100%;
    line-height: 1.35;
    white-space: normal;
  }
}
