:root {
  color-scheme: dark;
  --bg: #080d10;
  --bg-soft: #0d1418;
  --panel: rgba(18, 27, 32, .94);
  --panel-2: rgba(23, 34, 40, .88);
  --field: #0b1216;
  --line: rgba(170, 205, 214, .14);
  --line-strong: rgba(92, 232, 190, .38);
  --text: #edf7f5;
  --muted: #91a5ad;
  --faint: #60737b;
  --accent: #5ce8be;
  --accent-2: #8ab4ff;
  --danger: #ff7180;
  --warning: #f2c66f;
  --ok: #5ce8be;
  --shadow: 0 22px 70px rgba(0, 0, 0, .42);
  --glow: 0 0 22px rgba(92, 232, 190, .22);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 8%, rgba(92, 232, 190, .11), transparent 28%),
    radial-gradient(circle at 88% 6%, rgba(138, 180, 255, .10), transparent 28%),
    linear-gradient(135deg, #06090c, #0b1115 48%, #080d10);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei UI", "PingFang SC", Arial, sans-serif;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
input,
select,
textarea,
.chip,
.pill,
.permission-card {
  transition:
    border-color .18s ease,
    box-shadow .18s ease,
    transform .18s ease,
    background .18s ease,
    color .18s ease,
    opacity .18s ease;
}

.hidden {
  display: none !important;
}

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

.login-shell {
  width: min(460px, 100%);
}

.login-brand,
.side-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand {
  margin-bottom: 20px;
}

.login-brand h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.login-brand p,
.side-brand span,
.panel-head p,
.stat-card em,
.info-grid p,
.form-message,
.muted {
  margin: 0;
  color: var(--muted);
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(92, 232, 190, .55);
  background: linear-gradient(150deg, rgba(92, 232, 190, .12), rgba(138, 180, 255, .07));
  color: var(--accent);
  font-weight: 900;
  box-shadow: var(--glow), inset 0 0 18px rgba(92, 232, 190, .10);
  text-shadow: 0 0 16px rgba(92, 232, 190, .55);
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  border-radius: 10px;
}

.login-card,
.panel,
.modal,
.sidebar {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(21, 31, 37, .96), rgba(12, 19, 23, .96));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.login-card {
  padding: 22px;
  border-radius: var(--radius);
}

.login-card button[type="submit"] {
  margin-top: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  min-width: 0;
}

label span {
  font-size: 12px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(7, 13, 16, .92);
  color: var(--text);
  padding: 0 11px;
  outline: none;
}

textarea {
  min-height: 80px;
  resize: vertical;
  padding-top: 10px;
}

select {
  color: #101820;
  background:
    linear-gradient(180deg, rgba(237, 247, 245, .96), rgba(211, 225, 229, .96));
  border-color: rgba(255, 255, 255, .25);
}

input::placeholder,
textarea::placeholder {
  color: #5f737b;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: var(--glow), inset 0 0 0 1px rgba(92, 232, 190, .08);
}

button {
  min-height: 38px;
  border: 1px solid rgba(92, 232, 190, .42);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(50, 83, 75, .96), rgba(27, 48, 44, .96));
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

button:hover {
  border-color: rgba(92, 232, 190, .72);
  box-shadow: var(--glow);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.primary {
  color: #061410;
  background: linear-gradient(180deg, #6af3c7, #42cfa5);
  border-color: rgba(111, 255, 210, .74);
  font-weight: 700;
}

button.ghost {
  background: rgba(255, 255, 255, .045);
  color: var(--muted);
  border-color: var(--line);
}

button.danger {
  background: linear-gradient(180deg, rgba(95, 36, 47, .96), rgba(58, 20, 29, .96));
  border-color: rgba(255, 113, 128, .48);
  color: #ffd8dc;
}

button.icon-btn {
  width: 36px;
  padding: 0;
  font-size: 22px;
  background: rgba(255, 255, 255, .04);
  border-color: var(--line);
}

button.full {
  width: 100%;
}

.select-all-btn {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-color: rgba(138, 180, 255, .28);
  background: rgba(255, 255, 255, .045);
  color: var(--muted);
}

.select-all-btn.active {
  color: #061410;
  border-color: rgba(92, 232, 190, .70);
  background: linear-gradient(180deg, #6af3c7, #42cfa5);
  box-shadow: var(--glow);
}

.form-message {
  min-height: 22px;
  margin-top: 12px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-width: 0 1px 0 0;
  border-radius: 0;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.side-brand strong {
  display: block;
  font-size: 16px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 0 12px;
  box-shadow: none;
}

.tab-icon {
  width: 18px;
  height: 18px;
  position: relative;
  flex: 0 0 auto;
  border: 1px solid rgba(92, 232, 190, .34);
  border-radius: 5px;
  box-shadow: inset 0 0 10px rgba(92, 232, 190, .05);
}

.tab-icon::before,
.tab-icon::after {
  content: "";
  position: absolute;
  border-color: currentColor;
  opacity: .9;
}

.tab-icon[data-icon="dashboard"]::before {
  inset: 4px;
  border: 1px solid currentColor;
  border-top: 0;
  border-radius: 0 0 6px 6px;
}

.tab-icon[data-icon="users"]::before {
  width: 6px;
  height: 6px;
  border: 1px solid currentColor;
  border-radius: 50%;
  left: 5px;
  top: 3px;
}

.tab-icon[data-icon="users"]::after {
  width: 10px;
  height: 5px;
  border: 1px solid currentColor;
  border-radius: 8px 8px 0 0;
  left: 3px;
  bottom: 3px;
}

.tab-icon[data-icon="agents"]::before {
  width: 10px;
  height: 10px;
  border: 1px solid currentColor;
  border-radius: 3px;
  left: 3px;
  top: 3px;
}

.tab-icon[data-icon="agents"]::after {
  width: 5px;
  height: 5px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  right: 3px;
  bottom: 3px;
}

.tab-icon[data-icon="logs"]::before,
.tab-icon[data-icon="updates"]::before {
  width: 10px;
  height: 12px;
  border: 1px solid currentColor;
  border-radius: 2px;
  left: 3px;
  top: 2px;
}

.tab-icon[data-icon="logs"]::after {
  width: 8px;
  height: 1px;
  background: currentColor;
  left: 5px;
  top: 7px;
  box-shadow: 0 4px 0 currentColor;
}

.tab-icon[data-icon="updates"]::after {
  width: 7px;
  height: 7px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
  left: 5px;
  top: 3px;
}

.tab.active {
  color: var(--text);
  border-color: rgba(92, 232, 190, .32);
  background: linear-gradient(90deg, rgba(92, 232, 190, .14), rgba(138, 180, 255, .05));
  box-shadow: inset 3px 0 0 var(--accent), 0 0 18px rgba(92, 232, 190, .08);
}

.side-account {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .035);
}

.side-account span,
.side-account em {
  color: var(--muted);
  font-style: normal;
}

.side-account strong {
  font-size: 16px;
}

.content {
  min-width: 0;
  padding: 22px;
}

.content-head,
.panel-head,
.batch-bar,
.filter-bar,
.modal header,
.modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.content-head {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.content h2,
.panel h3,
.modal h3 {
  margin: 0;
  letter-spacing: 0;
}

.content h2 {
  font-size: 26px;
}

.panel {
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.panel-head {
  margin-bottom: 14px;
}

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

.stat-card,
.info-grid > div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .018));
  padding: 15px;
}

.tutorial-panel {
  cursor: pointer;
}

.tutorial-panel:hover {
  border-color: rgba(92, 232, 190, .30);
  box-shadow: var(--shadow), var(--glow);
}

.stat-card span,
.info-grid span {
  color: var(--muted);
  display: block;
}

.stat-card strong {
  display: block;
  margin: 4px 0;
  color: var(--accent);
  font-size: 26px;
  text-shadow: var(--glow);
}

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

.info-grid strong {
  display: block;
  margin: 6px 0;
}

.filter-bar {
  display: grid;
  grid-template-columns: 1.4fr .8fr .9fr auto;
  align-items: end;
  margin-bottom: 12px;
}

.filter-bar.log-filter {
  grid-template-columns: 1.1fr .8fr .8fr .8fr .8fr auto;
}

.filter-bar.tutorial-setting {
  grid-template-columns: minmax(0, 1fr) auto;
}

.batch-bar {
  justify-content: flex-start;
  flex-wrap: wrap;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .025);
  padding: 8px;
  margin-bottom: 12px;
}

.batch-bar span {
  color: var(--muted);
  margin-right: auto;
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .12);
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: rgba(14, 22, 26, .96);
}

.select-th {
  width: 82px;
}

td {
  color: #dce8e7;
}

tbody tr {
  transition: background .16s ease, box-shadow .16s ease;
}

tbody tr:hover {
  background: rgba(92, 232, 190, .045);
}

tbody tr.selectable-row {
  cursor: pointer;
}

tbody tr.selectable-row.selected {
  background: rgba(92, 232, 190, .085);
  box-shadow: inset 3px 0 0 rgba(92, 232, 190, .78);
}

tbody tr.selectable-row.disabled {
  cursor: default;
  opacity: .62;
}

.row-select-dot {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(145, 165, 173, .45);
  background: rgba(255, 255, 255, .035);
}

.row-select-dot::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: transparent;
  transition: background .16s ease, box-shadow .16s ease;
}

tr.selected .row-select-dot {
  border-color: rgba(92, 232, 190, .75);
  box-shadow: var(--glow);
}

tr.selected .row-select-dot::after {
  background: var(--accent);
  box-shadow: 0 0 12px rgba(92, 232, 190, .85);
}

.right {
  text-align: right;
}

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

.actions button {
  min-height: 32px;
  padding: 0 10px;
}

.pill,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  min-width: 54px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .045);
  color: var(--muted);
  margin: 2px 4px 2px 0;
  white-space: nowrap;
  word-break: keep-all;
  line-height: 1;
}

.pill.ok {
  color: var(--ok);
  border-color: rgba(92, 232, 190, .45);
  box-shadow: 0 0 14px rgba(92, 232, 190, .10);
}

.pill.bad {
  color: var(--danger);
  border-color: rgba(255, 113, 128, .45);
}

.pill.warn {
  color: var(--warning);
  border-color: rgba(242, 198, 111, .45);
}

.pill.info {
  color: var(--accent-2);
  border-color: rgba(138, 180, 255, .45);
}

.reason-inline {
  display: inline-block;
  max-width: 220px;
  margin-left: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.code {
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  color: #dffaf2;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, .62);
  animation: fadeIn .16s ease both;
}

.modal {
  width: min(720px, 100%);
  max-height: min(88vh, 820px);
  border-radius: var(--radius);
  overflow: hidden;
  animation: riseIn .18s ease both;
}

.modal header,
.modal footer {
  padding: 15px 16px;
  background: rgba(255, 255, 255, .025);
}

.modal header {
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.modal footer {
  border-top: 1px solid rgba(255, 255, 255, .08);
  justify-content: flex-end;
}

.modal-body {
  padding: 16px;
  overflow: auto;
  max-height: 62vh;
}

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

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

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.permission-card {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  background: rgba(255, 255, 255, .035);
  margin: 0;
  color: var(--muted);
  box-shadow: none;
  white-space: normal;
  text-align: left;
}

.permission-card:hover {
  border-color: rgba(92, 232, 190, .38);
  box-shadow: 0 0 16px rgba(92, 232, 190, .10);
}

.permission-card.selected {
  color: var(--text);
  border-color: rgba(92, 232, 190, .62);
  background: linear-gradient(90deg, rgba(92, 232, 190, .13), rgba(138, 180, 255, .05));
  box-shadow: var(--glow);
}

.permission-card.selected .row-select-dot {
  border-color: rgba(92, 232, 190, .75);
  box-shadow: var(--glow);
}

.permission-card.selected .row-select-dot::after {
  background: var(--accent);
  box-shadow: 0 0 12px rgba(92, 232, 190, .85);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  max-width: 420px;
  padding: 12px 14px;
  border: 1px solid rgba(92, 232, 190, .35);
  border-radius: var(--radius);
  background: rgba(14, 24, 28, .95);
  color: var(--text);
  box-shadow: var(--glow), var(--shadow);
  animation: riseIn .18s ease both;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px 10px;
}

.detail-json {
  max-width: 360px;
  white-space: pre-wrap;
  color: var(--muted);
  font-size: 12px;
}

.update-log-content {
  min-height: 120px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .16);
  color: #dce8e7;
  line-height: 1.75;
}

.toggle-card {
  flex-direction: row;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: rgba(255, 255, 255, .035);
}

.toggle-card input {
  width: auto;
  min-height: auto;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .tab {
    justify-content: center;
    text-align: center;
  }

  .tab-icon {
    display: none;
  }

  .side-account {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: center;
  }

  .stats-grid,
  .info-grid,
  .filter-bar,
  .filter-bar.log-filter,
  .form-grid,
  .permission-grid {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 16px;
  }
}

@media (max-width: 620px) {
  .login-brand h1,
  .content h2 {
    font-size: 22px;
  }

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

  .side-account {
    grid-template-columns: 1fr;
  }

  .content-head,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .modal {
    max-height: 92vh;
  }
}
