.plan-manager-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  min-height: 360px;
}

.plan-group-sidebar {
  min-width: 0;
  padding: 12px;
  border: 1px solid #ebeaf2;
  border-radius: 14px;
  background: #fafafd;
}

.plan-group-mobile-toggle { display: none; }
.plan-group-sidebar-content { display: block; }

.plan-group-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  padding: 3px 5px 10px;
  border-bottom: 1px solid #ecebf3;
}

.plan-group-side-head strong { color: #4b5264; font-size: 14px; }
.plan-group-side-head button,
.plan-group-tools button {
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 7px;
  color: #6858d5;
  background: #efedff;
}

.plan-group-filter-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.plan-group-filter {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border: 0;
  border-radius: 9px;
  color: #646b7d;
  background: transparent;
  font-size: 13px;
  text-align: left;
}

.plan-group-filter span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-group-filter em { color: #a2a6b3; font-size: 12px; font-style: normal; }
.plan-group-filter:hover { background: #f2f0fc; }
.plan-group-filter:focus-visible,
.plan-group-side-head button:focus-visible,
.plan-group-tools button:focus-visible,
.plan-table-actions button:focus-visible,
.inline-move-select:focus-visible,
.member-group-head:focus-visible,
.profile-device-head button:focus-visible {
  outline: 3px solid rgba(103, 84, 232, .2);
  outline-offset: 2px;
}
.plan-group-filter.active { color: #fff; background: linear-gradient(135deg, #7460ef, #5b47dc); }
.plan-group-filter.active em { color: rgba(255,255,255,.8); }
.plan-group-filter-row .plan-group-tools { display: none; align-items: center; gap: 3px; padding-left: 3px; }
.plan-group-filter-row:hover .plan-group-tools,
.plan-group-filter-row:focus-within .plan-group-tools { display: flex; }

.plan-table-wrap { min-width: 0; overflow-x: auto; border: 1px solid #ecebf2; border-radius: 14px; background: #fff; }
.plan-table-caption { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #ecebf2; }
.plan-table-caption strong { color: #3f4658; font-size: 14px; }
.plan-table-caption span { color: #747b8d; font-size: 12px; }
.plan-data-table { width: 100%; min-width: 1050px; border-collapse: collapse; font-size: 13px; }
.plan-data-table th,
.plan-data-table td { padding: 13px 12px; border-bottom: 1px solid #f0eff4; color: #596073; text-align: left; vertical-align: middle; }
.plan-data-table th { color: #737a8d; background: #fbfbfd; font-size: 12px; font-weight: 750; white-space: nowrap; }
.plan-data-table tbody tr:last-child td { border-bottom: 0; }
.plan-data-table tbody tr:hover { background: #fdfcff; }
.plan-data-table td > strong { color: #3e4557; }
.profile-data-table { min-width: 1120px; }
.profile-data-table td > strong,
.profile-data-table td > small { display: block; }
.profile-data-table td > small { margin-top: 4px; color: #9a9fac; }

.table-tag-list { max-width: 300px; display: flex; flex-wrap: wrap; gap: 5px; }
.table-tag-list span,
.all-members-badge { display: inline-flex; padding: 5px 8px; border-radius: 7px; color: #6256ba; background: #f0effd; font-size: 12px; white-space: nowrap; }
.table-tag-list em { align-self: center; color: #747b8d; font-size: 12px; font-style: normal; white-space: nowrap; }
.all-members-badge { color: #187a5e; background: #eaf8f3; }
.plan-device-cell strong,
.plan-device-cell small { display: block; white-space: nowrap; }
.plan-device-cell small { margin-top: 4px; color: #747b8d; font-size: 12px; }
.plan-device-cell i,
.profile-device-body i { width: 6px; height: 6px; display: inline-block; margin-right: 5px; border-radius: 50%; background: #a8acb6; }
.plan-device-cell i.online,
.profile-device-body i.online { background: #29aa7f; box-shadow: 0 0 0 3px rgba(41,170,127,.12); }
.plan-table-actions { display: flex; align-items: center; gap: 5px; min-width: 225px; }
.plan-table-actions button,
.inline-move-select { padding: 7px 9px; border: 0; border-radius: 7px; color: #6358c5; background: #f0effc; font-size: 12px; white-space: nowrap; }
.plan-table-actions button.danger { color: #c84e5a; background: #fff1f2; }
.plan-batch-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #ecebf2; background: #faf9ff; }
.plan-batch-toolbar > span { flex: 1; color: #635b7c; font-size: 13px; }
.plan-batch-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.plan-batch-actions button { padding: 8px 11px; font-size: 13px; }
.plan-batch-actions .danger { color: #bf3f51; }
.plan-data-table .plan-select-cell { width: 44px; min-width: 44px; }
.plan-select-cell input, .plan-batch-mobile-all input { width: 16px; height: 16px; padding: 0; accent-color: var(--primary); }
.plan-data-table tr.plan-selected { background: #f3f0ff; }
.plan-batch-mobile-all { display: none; align-items: center; gap: 8px; }
.customer-plan-batch-dialog.modal-card { border: 0; width: min(540px,calc(100% - 32px)); color: var(--ink); }
.customer-plan-batch-dialog::backdrop { background: rgba(19,23,36,.55); backdrop-filter: blur(5px); }
.customer-plan-batch-dialog [data-batch-body] { display: grid; gap: 12px; min-width: 0; }
.customer-plan-batch-dialog select { min-width: 0; }
.customer-plan-batch-dialog p { margin: 0; line-height: 1.7; }
.customer-plan-batch-dialog ul { max-height: 180px; overflow: auto; margin: 0; padding-left: 22px; line-height: 1.8; overflow-wrap: anywhere; }
.customer-plan-batch-dialog small { color: #737b8e; line-height: 1.6; }
.customer-plan-batch-dialog .batch-delete-confirm { background: #c44e60; }
@media (max-width: 900px) {
  .plan-batch-mobile-all { display: inline-flex; }
  .plan-batch-actions { width: 100%; }
  .plan-data-table .plan-select-cell { width: auto; }
}
.mini-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mini-switch span { width: 34px; height: 20px; display: block; position: relative; border-radius: 99px; background: #d9dbe2; transition: .2s; }
.mini-switch span::after { content: ''; width: 16px; height: 16px; position: absolute; top: 2px; left: 2px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.17); transition: .2s; }
.mini-switch input:checked + span { background: #6554e8; }
.mini-switch input:checked + span::after { transform: translateX(14px); }

.plan-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-help { margin: 0 0 10px; color: #737a8d; font-size: 13px; line-height: 1.6; }
.member-group-list,
.profile-device-groups { display: grid; gap: 8px; }
.member-group,
.profile-device-group { overflow: hidden; border: 1px solid #ebeaf2; border-radius: 11px; background: #fbfbfd; }
.member-group-head,
.profile-device-head > button:first-child { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; border: 0; color: #545b6e; background: transparent; text-align: left; }
.member-group-head span,
.profile-device-head > button:first-child span { min-width: 0; display: flex; align-items: center; gap: 8px; }
.member-group-head b,
.profile-device-head b { color: #8d92a2; transition: transform .2s; }
.member-group.open .member-group-head b,
.profile-device-group.open .profile-device-head b { transform: rotate(90deg); }
.member-group-head em { color: #6255cd; font-size: 12px; font-style: normal; }
.member-group-body,
.profile-device-body { display: none; padding: 0 12px 12px; }
.member-group.open .member-group-body,
.profile-device-group.open .profile-device-body { display: block; }
.member-picker-toolbar { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; margin-bottom: 9px; }
.member-picker-toolbar button { border: 0; border-radius: 8px; color: #6558c7; background: #f0effc; }
.member-options { max-height: 260px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; overflow: auto; }
.member-options label,
.profile-device-body label { min-width: 0; display: flex; align-items: center; gap: 8px; padding: 9px; border-radius: 9px; background: #f4f4f8; }
.member-options label:has(input:checked),
.profile-device-body label:has(input:checked) { background: #efedff; }
.member-options input,
.profile-device-body input { width: 15px; height: 15px; flex: 0 0 auto; accent-color: #6554e8; }
.member-options span,
.profile-device-body span { min-width: 0; }
.member-options strong,
.member-options small,
.profile-device-body strong,
.profile-device-body small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-options strong,
.profile-device-body strong { color: #4f5669; font-size: 13px; }
.member-options small,
.profile-device-body small { margin-top: 3px; color: #747b8d; font-size: 11px; }

.affiliate-policy { display: grid; gap: 10px; margin-top: 10px; }
.affiliate-policy > label:first-child { padding: 13px; border: 1px solid #ebe8ff; border-radius: 12px; background: #faf9ff; }
.affiliate-policy textarea { margin-top: 7px; }
.affiliate-switch.warning { border: 1px solid #ffe5be; background: #fff9ef; }

.send-profile-modal-card { width: min(920px, 100%); }
.send-profile-intervals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.send-profile-intervals fieldset > div { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.send-profile-intervals small { display: block; margin-top: 8px; color: #737a8d; font-size: 12px; }
.send-limit-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.send-limit-toolbar span { color: #737a8d; font-size: 12px; }
.send-limit-list { display: grid; gap: 7px; }
.send-limit-row { display: grid; grid-template-columns: 115px auto 115px auto minmax(90px,1fr) auto 30px; align-items: center; gap: 7px; }
.send-limit-row button { height: 34px; border: 0; border-radius: 8px; color: #c84e5a; background: #fff1f2; }
.profile-state { display: inline-flex; padding: 5px 8px; border-radius: 7px; font-size: 12px; }
.profile-state.on { color: #16805e; background: #e8f8f2; }
.profile-state.off { color: #8d92a0; background: #eff0f3; }
.profile-device-head { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; }
.profile-device-head > button:last-child { margin-right: 10px; padding: 7px 10px; border: 0; border-radius: 7px; color: #6457ca; background: #efedff; font-size: 12px; }
.profile-device-head span { display: grid !important; gap: 2px !important; }
.profile-device-head strong { font-size: 13px; }
.profile-device-head small { color: #747b8d; font-size: 11px; }
.profile-device-body { grid-template-columns: 1fr 1fr; gap: 7px; }
.profile-device-group.open .profile-device-body { display: grid; }

@media (max-width: 900px) {
  .plan-manager-layout { grid-template-columns: 1fr; gap: 12px; }
  .plan-group-sidebar { padding: 0; overflow: hidden; border-radius: 13px; background: #fff; }
  .plan-group-mobile-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 15px;
    border: 0;
    color: #444b5e;
    background: linear-gradient(135deg, #faf9ff, #f3f1ff);
    text-align: left;
  }
  .plan-group-mobile-toggle span,
  .plan-group-mobile-toggle strong,
  .plan-group-mobile-toggle small { display: block; min-width: 0; }
  .plan-group-mobile-toggle strong { font-size: 14px; }
  .plan-group-mobile-toggle small { margin-top: 3px; overflow: hidden; color: #737a8d; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
  .plan-group-mobile-toggle b { color: #6554df; font-size: 22px; line-height: 1; transform: rotate(90deg); transition: transform .2s; }
  .plan-group-sidebar.open .plan-group-mobile-toggle b { transform: rotate(-90deg); }
  .plan-group-sidebar-content { display: none; padding: 10px; border-top: 1px solid #eceaf5; }
  .plan-group-sidebar.open .plan-group-sidebar-content { display: block; }
  .plan-group-side-head { margin-bottom: 7px; padding: 2px 4px 9px; }
  .plan-group-filter-row { width: 100%; }
  .plan-group-filter { min-width: 0; padding: 11px 10px; }
  .plan-group-filter-row .plan-group-tools { display: flex; }
  .plan-table-wrap { overflow: visible; }
  .plan-data-table { min-width: 0; }
  .plan-data-table thead { display: none; }
  .plan-data-table,
  .plan-data-table tbody,
  .plan-data-table tr,
  .plan-data-table td { display: block; width: 100%; }
  .plan-data-table tbody { padding: 0 12px 12px; }
  .plan-data-table tbody tr { margin-top: 12px; padding: 5px 12px; border: 1px solid #eceaf5; border-radius: 12px; background: #fff; box-sizing: border-box; }
  .plan-data-table tbody tr:hover { background: #fff; }
  .plan-data-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 9px 0;
    border-bottom: 1px dashed #efedf5;
    box-sizing: border-box;
  }
  .plan-data-table td:last-child { border-bottom: 0; }
  .plan-data-table td::before { content: attr(data-label); color: #737a8d; font-size: 12px; font-weight: 700; }
  .plan-data-table .plan-empty-cell { display: block; padding: 18px 0; border: 0; }
  .plan-data-table .plan-empty-cell::before { display: none; }
  .table-tag-list { max-width: none; }
  .plan-table-actions { min-width: 0; flex-wrap: wrap; }
  .plan-form-grid,
  .send-profile-intervals { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .member-options,
  .profile-device-body { grid-template-columns: 1fr; }
  .send-limit-row { grid-template-columns: 1fr auto 1fr; }
  .send-limit-row input[type="number"] { grid-column: 1 / 3; }
  .send-limit-row button { grid-column: 3; grid-row: 2; }
}
