:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  background: #07111f;
  color: #e7eefb;
  --bg: #07111f;
  --bg-soft: #0a1628;
  --bg-strong: #030812;
  --panel: rgba(13, 27, 48, 0.78);
  --panel-strong: rgba(15, 31, 55, 0.94);
  --panel-soft: rgba(18, 39, 68, 0.72);
  --glass: rgba(255, 255, 255, 0.055);
  --cyan: #28e7ff;
  --cyan-soft: rgba(40, 231, 255, 0.14);
  --blue: #3a8bff;
  --blue-dark: #0f66e8;
  --violet: #9b7cff;
  --green: #31e6a2;
  --amber: #ffcc66;
  --red: #ff5c7a;
  --ink: #eff6ff;
  --muted: #8fa4c2;
  --muted-strong: #b6c5da;
  --line: rgba(139, 170, 210, 0.22);
  --line-strong: rgba(40, 231, 255, 0.42);
  --field: rgba(5, 13, 25, 0.72);
  --shadow: 0 22px 58px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 14px 34px rgba(0, 0, 0, 0.22);
  --glow: 0 0 0 1px rgba(40, 231, 255, 0.16), 0 18px 44px rgba(15, 102, 232, 0.16);
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(120deg, rgba(58, 139, 255, 0.1) 0 1px, transparent 1px 80px),
    linear-gradient(210deg, rgba(40, 231, 255, 0.075) 0 1px, transparent 1px 96px),
    linear-gradient(145deg, #050b15 0%, #081426 42%, #0b1b31 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(40, 231, 255, 0.1), transparent 28%),
    linear-gradient(90deg, rgba(155, 124, 255, 0.08), transparent 42%),
    linear-gradient(0deg, rgba(5, 10, 19, 0.8), transparent 54%);
  pointer-events: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

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

h1 {
  font-size: 19px;
  line-height: 1.2;
}

h2 {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: clamp(24px, 2.1vw, 34px);
  line-height: 1.12;
  text-shadow: 0 0 26px rgba(40, 231, 255, 0.16);
}

h3 {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
}

.shell {
  width: 100%;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

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

.login-card {
  position: relative;
  width: min(440px, 100%);
  border: 1px solid rgba(40, 231, 255, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(19, 41, 72, 0.92), rgba(8, 19, 35, 0.94)),
    var(--panel-strong);
  box-shadow: var(--shadow), 0 0 70px rgba(40, 231, 255, 0.08);
  padding: 30px;
  overflow: hidden;
}

.login-card::before,
.panel::before,
.status-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(40, 231, 255, 0.86), rgba(155, 124, 255, 0.54), transparent);
  pointer-events: none;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 26px;
}

.brand-row.compact {
  margin-bottom: 2px;
}

.brand-row > div {
  display: grid;
  gap: 4px;
}

.brand-row p,
.panel-head p,
#groupId,
.empty-state p,
.field-hint {
  color: var(--muted);
}

.brand-mark {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border: 1px solid rgba(40, 231, 255, 0.4);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(58, 139, 255, 0.96), rgba(40, 231, 255, 0.86)),
    #1274ff;
  color: #fff;
  font-weight: 900;
  box-shadow: 0 14px 34px rgba(40, 231, 255, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 6px;
  pointer-events: none;
}

.form,
.settings,
.panel {
  display: grid;
  gap: 14px;
}

label,
.field {
  display: grid;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  outline: none;
  padding: 10px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input::placeholder,
textarea::placeholder {
  color: rgba(143, 164, 194, 0.72);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: rgba(40, 231, 255, 0.72);
  background: rgba(5, 13, 25, 0.88);
  box-shadow: 0 0 0 4px rgba(40, 231, 255, 0.11), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.primary,
.secondary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.primary {
  position: relative;
  flex: 0 0 auto;
  border: 1px solid rgba(40, 231, 255, 0.5);
  background:
    linear-gradient(135deg, rgba(58, 139, 255, 0.98), rgba(40, 231, 255, 0.86)),
    var(--blue);
  color: #fff;
  padding: 0 18px;
  box-shadow: 0 14px 30px rgba(40, 231, 255, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.24);
  overflow: hidden;
}

.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 0 34%, rgba(255, 255, 255, 0.2) 50%, transparent 66% 100%);
  transform: translateX(-120%);
  transition: transform 320ms ease;
}

.primary:hover:not(:disabled),
.ghost:hover {
  transform: translateY(-1px);
}

.primary:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.56);
  box-shadow: 0 18px 38px rgba(40, 231, 255, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.primary:hover:not(:disabled)::after {
  transform: translateX(120%);
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  box-shadow: none;
}

.primary.full {
  width: 100%;
}

.secondary {
  flex: 0 0 auto;
  border: 1px solid rgba(40, 231, 255, 0.34);
  background: linear-gradient(135deg, rgba(40, 231, 255, 0.12), rgba(58, 139, 255, 0.14));
  color: #d8f8ff;
  padding: 0 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.secondary:hover:not(:disabled) {
  border-color: rgba(40, 231, 255, 0.72);
  background: linear-gradient(135deg, rgba(40, 231, 255, 0.18), rgba(58, 139, 255, 0.18));
  transform: translateY(-1px);
}

.secondary:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.mini-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.ghost {
  width: 100%;
  border: 1px solid rgba(143, 164, 194, 0.24);
  background: rgba(255, 255, 255, 0.055);
  color: #dce8f6;
}

.ghost.light,
.ghost.danger {
  width: auto;
  padding: 0 12px;
}

.ghost.light {
  border-color: rgba(40, 231, 255, 0.25);
  background: rgba(40, 231, 255, 0.08);
  color: #d8f8ff;
}

.ghost.danger,
.mini-remove {
  border-color: rgba(255, 92, 122, 0.3);
  background: rgba(255, 92, 122, 0.09);
  color: #ffd5dd;
}

.message {
  min-height: 22px;
  color: var(--amber);
  font-size: 14px;
}

.message.floating {
  position: sticky;
  right: 0;
  bottom: 18px;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  border: 1px solid rgba(40, 231, 255, 0.28);
  border-radius: 8px;
  background: rgba(5, 13, 25, 0.92);
  padding: 8px 12px;
  box-shadow: var(--shadow-soft);
  overflow-wrap: anywhere;
}

.message.floating:empty {
  display: none;
}

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

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  display: grid;
  grid-template-rows: auto auto auto auto;
  align-content: start;
  gap: 18px;
  width: 272px;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid rgba(40, 231, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(10, 22, 40, 0.96), rgba(3, 8, 18, 0.98)),
    var(--bg-strong);
  color: #fff;
  padding: 20px 16px;
  box-shadow: 16px 0 44px rgba(0, 0, 0, 0.28);
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, rgba(40, 231, 255, 0.55), transparent);
  pointer-events: none;
}

.sidebar .brand-row p {
  color: #9fb0ca;
}

.sidebar-block {
  display: grid;
  gap: 10px;
}

.group-block {
  min-height: 0;
  align-content: start;
  grid-template-rows: auto auto;
}

.block-title {
  color: #78eafe;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.group-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  max-height: calc(100vh - 304px);
  overflow-y: auto;
  padding-right: 2px;
}

.group-list::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 8px;
}

.group-list::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(40, 231, 255, 0.24);
}

.group-list p {
  border: 1px dashed rgba(40, 231, 255, 0.25);
  border-radius: 8px;
  background: rgba(40, 231, 255, 0.055);
  color: #aebed4;
  line-height: 1.65;
  padding: 14px;
}

.group-item {
  position: relative;
  display: grid;
  width: 100%;
  gap: 5px;
  border: 1px solid rgba(143, 164, 194, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: #fff;
  cursor: pointer;
  padding: 12px 13px;
  text-align: left;
  overflow: hidden;
  overflow-wrap: anywhere;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.group-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: transparent;
  transition: background 160ms ease;
}

.group-item:hover,
.group-item.active {
  border-color: rgba(40, 231, 255, 0.62);
  background: linear-gradient(135deg, rgba(58, 139, 255, 0.22), rgba(40, 231, 255, 0.1));
  box-shadow: 0 10px 24px rgba(40, 231, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.group-item:hover {
  transform: translateX(1px);
}

.group-item:hover::before,
.group-item.active::before {
  background: var(--cyan);
}

.group-name {
  display: block;
  color: #fff;
  font-weight: 800;
  line-height: 1.35;
}

.group-item small {
  display: block;
  color: rgba(225, 236, 249, 0.72);
  font-size: 12px;
  line-height: 1.45;
}

.workspace {
  display: grid;
  align-content: start;
  justify-items: center;
  width: 100%;
  grid-column: 2;
  padding: 26px clamp(18px, 2.8vw, 38px) 38px;
}

.topbar,
.status-strip,
.settings {
  width: min(100%, 1160px);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  border: 1px solid rgba(40, 231, 255, 0.14);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(15, 31, 55, 0.72), rgba(5, 13, 25, 0.58));
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.topbar > div {
  display: grid;
  gap: 7px;
}

#groupId {
  max-width: 780px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.eyebrow {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 360px;
  border: 1px dashed rgba(40, 231, 255, 0.3);
  border-radius: 8px;
  background: rgba(15, 31, 55, 0.5);
  text-align: center;
  padding: 28px;
}

.empty-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(40, 231, 255, 0.32);
  border-radius: 8px;
  background: rgba(40, 231, 255, 0.09);
  color: var(--cyan);
  font-size: 30px;
  font-weight: 300;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.status-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  border: 1px solid rgba(40, 231, 255, 0.18);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(15, 31, 55, 0.82), rgba(7, 17, 31, 0.78));
  padding: 14px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.status-card small {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
}

.status-card strong {
  display: block;
  color: var(--ink);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.status-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: 0 0 0 5px rgba(148, 163, 184, 0.14), 0 0 18px rgba(148, 163, 184, 0.24);
}

.status-dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(49, 230, 162, 0.14), 0 0 22px rgba(49, 230, 162, 0.45);
}

.status-dot.bad {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(255, 92, 122, 0.13), 0 0 20px rgba(255, 92, 122, 0.34);
}

.status-dot.neutral {
  background: var(--cyan);
  box-shadow: 0 0 0 5px rgba(40, 231, 255, 0.13), 0 0 22px rgba(40, 231, 255, 0.4);
}

.panel {
  position: relative;
  border: 1px solid rgba(143, 164, 194, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(15, 31, 55, 0.88), rgba(9, 20, 36, 0.86)),
    var(--panel);
  padding: 18px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.panel:hover {
  border-color: rgba(40, 231, 255, 0.3);
  box-shadow: var(--glow);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 0;
}

.panel-head.compact-head {
  align-items: center;
}

.panel-head > div {
  display: grid;
  gap: 5px;
}

.panel-head p {
  line-height: 1.55;
}

.bot-api-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.grid {
  display: grid;
  gap: 12px;
}

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

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

.wide {
  grid-column: 1 / -1;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.setting-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  border: 1px solid rgba(143, 164, 194, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 11px 12px;
  color: var(--muted-strong);
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.setting-check.panel-action {
  min-height: 38px;
  flex: 0 0 auto;
  padding: 9px 12px;
  white-space: nowrap;
}

.setting-check.wide {
  min-height: 54px;
}

.setting-check input {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  accent-color: var(--cyan);
  cursor: pointer;
}

.setting-check span {
  display: block;
}

.setting-check:has(input:checked) {
  border-color: rgba(40, 231, 255, 0.52);
  background: linear-gradient(135deg, rgba(40, 231, 255, 0.1), rgba(58, 139, 255, 0.1));
  box-shadow: inset 0 0 0 1px rgba(40, 231, 255, 0.08);
  color: #e9fbff;
}

.setting-check:hover {
  border-color: rgba(40, 231, 255, 0.38);
}

.setting-switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  border: 1px solid rgba(143, 164, 194, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted-strong);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  padding: 7px 10px;
  white-space: nowrap;
}

.setting-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch-ui {
  position: relative;
  width: 36px;
  height: 20px;
  flex: 0 0 36px;
  border-radius: 999px;
  background: rgba(143, 164, 194, 0.34);
  box-shadow: inset 0 0 0 1px rgba(20, 32, 51, 0.18);
  transition: background 160ms ease, box-shadow 160ms ease;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
  transition: transform 160ms ease;
}

.setting-switch:has(input:checked) {
  border-color: rgba(40, 231, 255, 0.48);
  background: linear-gradient(135deg, rgba(40, 231, 255, 0.13), rgba(58, 139, 255, 0.12));
  color: #e5fbff;
}

.setting-switch:has(input:checked) .switch-ui {
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  box-shadow: 0 0 0 3px rgba(40, 231, 255, 0.11), 0 0 18px rgba(40, 231, 255, 0.28);
}

.setting-switch:has(input:checked) .switch-ui::after {
  transform: translateX(16px);
}

.login-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: -2px;
}

.mini-switch {
  flex: 1 1 130px;
  justify-content: center;
}

.command-permission-row {
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: start;
  gap: 10px 14px;
  border: 1px solid rgba(143, 164, 194, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
}

.command-permission-row > span {
  padding-top: 9px;
  font-weight: 800;
}

.command-permission-row textarea {
  min-height: 74px;
}

.command-permission-row .field-hint {
  grid-column: 2;
  margin-top: -2px;
}

.compact-field {
  min-height: 54px;
}

.compact-field input {
  min-height: 38px;
  padding-top: 9px;
  padding-bottom: 9px;
}

.rule-editor {
  display: grid;
  gap: 10px;
}

.rule-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 900;
}

.rule-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.rule-list {
  display: grid;
  gap: 10px;
}

.rule-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.25fr) minmax(220px, 1fr) minmax(220px, 0.8fr) auto;
  align-items: start;
  gap: 10px;
  border: 1px solid rgba(143, 164, 194, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
}

.scheduled-row {
  grid-template-columns: minmax(140px, 0.22fr) minmax(220px, 1fr) minmax(220px, 0.8fr) auto;
}

.rule-row textarea {
  min-height: 74px;
  resize: vertical;
}

.rule-row input[type="number"] {
  min-height: 74px;
}

.mini-remove {
  width: auto;
  min-height: 38px;
  padding: 0 12px;
}

@media (max-width: 1120px) {
  .app {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .sidebar {
    width: 250px;
  }

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

@media (max-width: 900px) {
  .app {
    display: block;
  }

  .sidebar {
    position: static;
    display: grid;
    width: auto;
    height: auto;
    overflow: visible;
    padding: 18px;
  }

  .group-block {
    min-height: 0;
  }

  .group-list {
    max-height: 220px;
  }

  .workspace {
    grid-column: auto;
    padding: 18px 14px 28px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-head.compact-head {
    align-items: stretch;
  }

  .primary {
    width: 100%;
  }

  .bot-api-row {
    grid-template-columns: 1fr;
  }

  .secondary {
    width: 100%;
  }

  .status-strip,
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .command-permission-row {
    grid-template-columns: 1fr;
  }

  .command-permission-row > span {
    padding-top: 0;
  }

  .command-permission-row .field-hint {
    grid-column: auto;
  }

  .rule-row,
  .scheduled-row {
    grid-template-columns: 1fr;
  }

  .rule-editor-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .rule-actions > button {
    flex: 1 1 120px;
  }

  .mini-remove {
    width: 100%;
  }
}

@media (max-width: 560px) {
  body {
    min-width: 0;
  }

  .login-view,
  .login-card,
  .panel,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    padding: 16px;
  }

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

  .status-card {
    padding: 14px;
  }
}
