:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --border: #d8e0ea;
  --text: #17202a;
  --muted: #617085;
  --accent: #2563eb;
  --accent-soft: #dbe7ff;
  --success: #0f8f61;
  --success-soft: #dff8ec;
  --warning: #b7791f;
  --warning-soft: #fff1cc;
  --danger: #c2414b;
  --danger-soft: #ffe2e5;
  --shadow: 0 10px 24px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

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

.login-panel {
  width: min(100%, 380px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-mark,
.avatar {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #0f8f61);
  color: #ffffff;
  font-weight: 800;
}

.login-panel h1,
.topbar h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  margin-top: 16px;
  margin-bottom: 24px;
  font-size: 24px;
}

.login-panel label,
.presence-form label,
.config-form label,
.search-box label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  padding: 9px 11px;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-panel button,
.presence-form button,
.config-form button {
  width: 100%;
  min-height: 40px;
  margin-top: 16px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.message {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--danger);
}

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

.sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 18px;
  height: 100vh;
  padding: 18px;
  border-right: 1px solid var(--border);
  background: #ffffff;
}

.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.avatar {
  overflow: hidden;
}

.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-copy {
  min-width: 0;
}

.brand-copy strong,
.brand-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.guild-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.guild-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.guild-item:hover,
.guild-item.is-active {
  border-color: var(--border);
  background: var(--surface-2);
}

.guild-item strong,
.guild-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guild-item small {
  color: var(--muted);
}

.pill {
  align-self: start;
  min-width: 58px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.pill.warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.pill.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.secondary-button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-weight: 800;
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h1 {
  font-size: 26px;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
}

.tabs {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.tab {
  min-width: 96px;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.is-active {
  background: var(--accent);
  color: #ffffff;
}

.view {
  display: grid;
  gap: 18px;
}

.error-banner {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
}

.error-banner div {
  display: grid;
  gap: 2px;
}

.error-banner strong,
.error-banner span {
  overflow-wrap: anywhere;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

.stat-card,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(23, 32, 42, 0.03);
}

.stat-card {
  min-height: 104px;
  padding: 16px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1.1;
}

.stat-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

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

.panel {
  min-width: 0;
  padding: 16px;
}

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

.panel h2 {
  font-size: 16px;
}

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

.switch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.switch-row strong,
.switch-row span {
  display: block;
  overflow-wrap: anywhere;
}

.switch-row span {
  color: var(--muted);
  font-size: 13px;
}

.switch-row input {
  appearance: none;
  width: 46px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #c7d0dd;
  position: relative;
}

.switch-row input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(23, 32, 42, 0.2);
  transition: transform 160ms ease;
}

.switch-row input:checked {
  background: var(--accent);
}

.switch-row input:checked::after {
  transform: translateX(20px);
}

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

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

.presence-form button,
.config-form button {
  margin-top: 0;
}

.server-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.server-header h2 {
  margin: 0 0 4px;
  font-size: 22px;
  overflow-wrap: anywhere;
}

.server-header p {
  margin: 0;
  color: var(--muted);
}

.data-list {
  display: grid;
  gap: 9px;
}

.data-row {
  display: grid;
  gap: 5px;
  min-height: 52px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.data-row strong,
.data-row span,
.data-row small {
  overflow-wrap: anywhere;
}

.data-row span,
.data-row small {
  color: var(--muted);
}

.empty-state {
  min-height: 68px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 12px;
}

.full-width {
  grid-column: 1 / -1;
}

.table-wrap {
  max-height: 420px;
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.table-bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 72px;
  gap: 10px;
  align-items: center;
}

.bar-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--success));
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #17202a;
  color: #ffffff;
  box-shadow: var(--shadow);
}

@media (max-width: 1120px) {
  .stat-grid,
  .content-grid,
  .content-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

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

  .guild-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 260px);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .server-header {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .stat-grid,
  .content-grid,
  .content-grid.three,
  .switch-grid,
  .presence-form,
  .config-form,
  .embed-workbench,
  .config-editor-row,
  .role-reward-row,
  .embed-builder,
  .builder-row,
  .embed-button-row,
  .embed-select-row,
  .embed-select-option-row {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: minmax(90px, 120px) minmax(0, 1fr) 56px;
  }
}

@media (max-width: 520px) {
  .login-panel,
  .panel,
  .server-header,
  .stat-card {
    border-radius: 6px;
  }

  .workspace {
    padding: 12px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .stat-card strong {
    font-size: 24px;
  }
}

/* Modern dashboard refresh */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #d8dee8;
  --text: #111827;
  --muted: #637083;
  --accent: #315bea;
  --accent-soft: #e9efff;
  --success: #0b8f69;
  --success-soft: #e0f7ee;
  --warning: #a46412;
  --warning-soft: #fff3d6;
  --danger: #c9364d;
  --danger-soft: #ffe5ea;
  --shadow: 0 18px 44px rgba(17, 24, 39, 0.12);
}

body {
  background: var(--bg);
}

.app-shell {
  grid-template-columns: 316px minmax(0, 1fr);
}

.sidebar {
  padding: 20px;
  background: #111827;
  border-right: 0;
  color: #ffffff;
}

.brand-copy span,
.sidebar .muted,
.sidebar .search-box label {
  color: #aeb8c7;
}

.search-box input {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.guild-item {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
}

.guild-item small {
  color: #aeb8c7;
}

.guild-item:hover,
.guild-item.is-active {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.11);
}

.sidebar .secondary-button {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.workspace {
  padding: 28px;
}

.topbar {
  margin-bottom: 16px;
}

.topbar h1 {
  font-size: 30px;
  line-height: 1.1;
}

.tabs {
  width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: initial;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
}

.tab {
  min-width: 0;
}

.stat-grid {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}

.stat-card,
.panel,
.server-header,
.action-bar {
  border-color: rgba(130, 146, 170, 0.34);
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
}

.stat-card,
.panel {
  background: var(--surface);
}

.stat-card strong {
  color: var(--text);
}

.panel-head h2 {
  font-size: 15px;
  text-transform: uppercase;
  color: #1f2937;
}

.primary-button,
.danger-button,
.login-panel button,
.presence-form button,
.config-form button,
.control-form button[type="submit"] {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.primary-button:hover,
.login-panel button:hover,
.presence-form button:hover,
.config-form button:hover,
.control-form button[type="submit"]:hover {
  filter: brightness(0.96);
}

.danger-button {
  background: var(--danger);
}

.secondary-button.compact,
.compact {
  width: auto;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

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

.control-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.backup-actions {
  display: grid;
  grid-template-columns: minmax(140px, 0.75fr) minmax(150px, 0.75fr) minmax(180px, 1.35fr) minmax(140px, 0.8fr);
  gap: 10px;
  align-items: end;
}

.backup-download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.file-picker {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.file-picker input {
  min-height: 40px;
  padding: 7px 9px;
}

.embed-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.72fr);
  gap: 16px;
  align-items: start;
}

.embed-builder {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015)),
    #0f1622;
}

.embed-builder label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.builder-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.builder-head h3 {
  margin: 0;
  font-size: 14px;
}

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

.code-input {
  width: 100%;
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}

.json-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.json-toggle {
  min-height: 0;
  white-space: nowrap;
}

.embed-preview-panel {
  position: sticky;
  top: 76px;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(49, 198, 178, 0.08), rgba(255, 255, 255, 0.025)),
    #101722;
}

.embed-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.embed-preview-head span,
.embed-preview-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.embed-preview-head strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.embed-preview-head small {
  padding: 4px 8px;
  border: 1px solid rgba(49, 198, 178, 0.28);
  border-radius: 999px;
  color: var(--accent);
}

.embed-preview-head small.is-error {
  border-color: rgba(255, 100, 124, 0.32);
  color: var(--danger);
}

.discord-preview {
  min-height: 240px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: #313338;
  color: #f2f3f5;
}

.discord-message {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.discord-avatar {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #5865f2, #23a55a);
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.discord-message-body {
  min-width: 0;
}

.discord-message-head {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: baseline;
  margin-bottom: 4px;
}

.discord-message-head strong {
  color: #ffffff;
  font-size: 15px;
}

.discord-message-head span {
  color: #949ba4;
  font-size: 12px;
}

.discord-content,
.discord-embed-description,
.discord-embed-field span {
  color: #dbdee1;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.discord-embed {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  max-width: 520px;
  margin-top: 8px;
  padding: 12px;
  border-left: 4px solid var(--embed-color, #5865f2);
  border-radius: 4px;
  background: #2b2d31;
}

.discord-embed-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.discord-embed-author,
.discord-embed-footer {
  color: #dbdee1;
  font-size: 12px;
  font-weight: 700;
}

.discord-embed-title {
  color: #ffffff;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.discord-embed-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 2px;
}

.discord-embed-field {
  display: grid;
  gap: 3px;
  grid-column: 1 / -1;
  min-width: 0;
}

.discord-embed-field.is-inline {
  grid-column: span 1;
}

.discord-embed-field strong {
  color: #ffffff;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.discord-embed-thumbnail {
  width: 82px;
  height: 82px;
  object-fit: cover;
  border-radius: 4px;
}

.discord-embed-image {
  width: min(100%, 420px);
  max-height: 280px;
  object-fit: cover;
  border-radius: 4px;
}

.discord-components {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.discord-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.discord-button {
  min-height: 32px;
  padding: 6px 13px;
  border: 0;
  border-radius: 4px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  opacity: 1;
}

.discord-button.is-primary {
  background: #5865f2;
}

.discord-button.is-secondary,
.discord-button.is-link {
  background: #4e5058;
}

.discord-button.is-success {
  background: #248046;
}

.discord-button.is-danger {
  background: #da373c;
}

.discord-select-preview {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  max-width: 360px;
  padding: 8px 10px;
  border: 1px solid #4e5058;
  border-radius: 4px;
  background: #313338;
  color: #b5bac1;
}

.discord-select-preview span,
.discord-select-preview small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.embed-preview-empty {
  display: grid;
  min-height: 190px;
  place-content: center;
  gap: 6px;
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #b5bac1;
  text-align: center;
}

.embed-preview-empty strong {
  color: #ffffff;
}

.builder-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

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

.embed-button-row,
.embed-select-row,
.embed-select-option-row {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
}

.check-row {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.embed-builder button[type="submit"] {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.config-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.config-form .wide,
.config-form button[type="submit"] {
  grid-column: 1 / -1;
}

.config-custom-editor {
  display: grid;
  gap: 12px;
}

.custom-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.custom-editor-head div {
  display: grid;
  gap: 4px;
}

.custom-editor-head span {
  color: var(--muted);
  font-size: 0.9rem;
}

.config-editor-list,
.role-reward-list {
  display: grid;
  gap: 10px;
}

.config-editor-row,
.role-reward-row {
  display: grid;
  grid-template-columns: 32px minmax(120px, 0.35fr) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.invite-role-row,
.invite-count-row {
  grid-template-columns: 32px minmax(180px, 1fr) minmax(180px, 1fr) auto;
}

.sticky-row {
  grid-template-columns: 32px minmax(180px, 0.4fr) minmax(240px, 1fr) auto;
  align-items: start;
}

.sticky-row textarea {
  min-height: 92px;
  resize: vertical;
}

@media (max-width: 640px) {
  .sticky-row {
    grid-template-columns: 1fr;
  }
}

.setting-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

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

.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.config-form button.token-button {
  width: auto;
  min-height: 34px;
  margin: 0;
  padding-inline: 12px;
}

.reward-index {
  align-self: center;
  color: var(--muted);
  font-weight: 800;
}

.config-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.config-cell span {
  overflow-wrap: anywhere;
}

.config-risk td {
  background: var(--danger-soft);
}

.action-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.7fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.action-group,
.danger-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.danger-group {
  justify-content: end;
}

.danger-group input {
  max-width: 240px;
}

.server-control-panel {
  overflow: hidden;
}

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

.control-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.control-card h3 {
  margin: 0 0 2px;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.compact-card {
  align-content: start;
}

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

.button-row button {
  width: 100%;
  margin-top: 0;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.mini-card {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.mini-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mini-card strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.owner-server-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.owner-server-row strong,
.owner-server-row span {
  display: block;
  overflow-wrap: anywhere;
}

.owner-server-row span {
  color: var(--muted);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 24, 39, 0.48);
}

.modal-panel {
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 900;
}

.modal-search {
  min-height: 42px;
}

.picker-list {
  min-height: 220px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 2px;
}

.picker-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.picker-option:hover,
.picker-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.picker-option img,
.swatch {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.picker-option img {
  object-fit: cover;
}

.swatch {
  display: block;
  border: 1px solid rgba(17, 24, 39, 0.12);
}

.muted-swatch {
  background: var(--surface-3);
}

.picker-option strong,
.picker-option small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-option small {
  color: var(--muted);
}

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

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

  .sidebar {
    background: #111827;
  }

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

  .action-bar,
  .control-form,
  .backup-actions,
  .mini-grid {
    grid-template-columns: 1fr;
  }

  .action-group,
  .danger-group,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .danger-group input {
    max-width: none;
  }

  .config-cell,
  .owner-server-row {
    grid-template-columns: 1fr;
  }
}

/* Discord-style dark control room */
:root {
  --bg: #080d1a;
  --surface: rgba(23, 28, 44, 0.94);
  --surface-2: rgba(32, 38, 58, 0.92);
  --surface-3: #101827;
  --border: rgba(154, 170, 203, 0.18);
  --text: #f4f7fb;
  --muted: #a7b1c2;
  --accent: #5865f2;
  --accent-soft: rgba(88, 101, 242, 0.2);
  --success: #42d392;
  --success-soft: rgba(66, 211, 146, 0.14);
  --warning: #f5b94c;
  --warning-soft: rgba(245, 185, 76, 0.14);
  --danger: #ff5c7a;
  --danger-soft: rgba(255, 92, 122, 0.14);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

body {
  background:
    linear-gradient(135deg, #16033d 0%, #0f2168 45%, #063c64 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.48), rgba(0, 0, 0, 0.08));
}

.app-shell {
  background: rgba(5, 9, 20, 0.35);
  backdrop-filter: blur(14px);
}

.sidebar {
  background: rgba(9, 14, 28, 0.9);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 12px 0 34px rgba(0, 0, 0, 0.18);
}

.workspace {
  position: relative;
}

.topbar h1,
.server-header h2,
.panel h2 {
  color: var(--text);
}

.topbar p,
.brand-copy span,
.guild-item small,
.data-row span,
.data-row small,
.owner-server-row span,
.panel-head .muted,
.muted {
  color: var(--muted);
}

.login-panel,
.stat-card,
.panel,
.server-header,
.action-bar,
.tabs,
.modal-panel {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel {
  backdrop-filter: blur(20px);
}

.login-mark,
.avatar {
  background: linear-gradient(135deg, #5865f2, #1fb6ff);
  box-shadow: 0 12px 30px rgba(88, 101, 242, 0.34);
}

input,
select,
textarea {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(8, 13, 26, 0.72);
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #7f8ca1;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(88, 101, 242, 0.9);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.22);
}

.secondary-button,
.icon-button {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.secondary-button:hover,
.icon-button:hover {
  border-color: rgba(88, 101, 242, 0.86);
  color: #ffffff;
  background: rgba(88, 101, 242, 0.16);
}

.primary-button,
.danger-button,
.login-panel button,
.presence-form button,
.config-form button,
.control-form button[type="submit"],
.embed-builder button[type="submit"] {
  background: linear-gradient(135deg, #5865f2, #2f7dff);
  box-shadow: 0 10px 24px rgba(47, 125, 255, 0.24);
}

.danger-button {
  background: linear-gradient(135deg, #ff5c7a, #d93655);
}

.tabs {
  background: rgba(12, 18, 34, 0.78);
}

.tab {
  color: var(--muted);
}

.tab.is-active {
  background: linear-gradient(135deg, #5865f2, #2f7dff);
  color: #ffffff;
}

.guild-item {
  background: rgba(255, 255, 255, 0.045);
}

.guild-item:hover,
.guild-item.is-active {
  border-color: rgba(88, 101, 242, 0.55);
  background: rgba(88, 101, 242, 0.16);
}

.pill {
  background: var(--success-soft);
  color: var(--success);
}

.pill.warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.pill.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.stat-card,
.mini-card,
.switch-row,
.picker-option,
.builder-section {
  background: var(--surface-2);
}

.stat-card strong,
.mini-card strong {
  color: #ffffff;
}

.panel-head h2 {
  color: #dfe6f2;
  text-transform: none;
}

.switch-row {
  border-color: rgba(255, 255, 255, 0.1);
}

.switch-row input {
  background: #354057;
}

.switch-row input:checked {
  background: linear-gradient(135deg, #5865f2, #1fb6ff);
}

.table-wrap,
th,
td,
.data-row,
.owner-server-row,
.mini-card,
.builder-section,
.builder-row {
  border-color: rgba(255, 255, 255, 0.1);
}

th {
  background: rgba(12, 18, 34, 0.98);
  color: #c5cfdd;
}

.config-risk td {
  background: rgba(255, 92, 122, 0.11);
}

.bar-track,
.empty-state,
.muted-swatch {
  background: rgba(255, 255, 255, 0.07);
}

.bar-fill {
  background: linear-gradient(90deg, #5865f2, #42d392);
}

.modal-overlay {
  background: rgba(3, 6, 14, 0.74);
  backdrop-filter: blur(10px);
}

.picker-option.is-selected,
.picker-option:hover {
  background: rgba(88, 101, 242, 0.2);
}

.toast {
  background: #101827;
  border-color: rgba(255, 255, 255, 0.16);
}

@media (max-width: 640px) {
  .workspace {
    padding: 26px 20px;
  }

  .stat-grid,
  .content-grid,
  .content-grid.three,
  .switch-grid,
  .presence-form,
  .config-form,
  .control-form,
  .embed-workbench,
  .embed-builder,
  .builder-row,
  .embed-button-row,
  .embed-select-row,
  .embed-select-option-row {
    grid-template-columns: 1fr;
  }

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

  .tab {
    min-width: 0;
  }

  .stat-card {
    min-height: 96px;
  }
}

/* 2026 admin dashboard polish */
:root {
  --bg: #0b0f17;
  --surface: #121824;
  --surface-2: #171f2d;
  --surface-3: #202a3a;
  --border: rgba(180, 193, 214, 0.14);
  --text: #eef3f8;
  --muted: #9aa8ba;
  --accent: #31c6b2;
  --accent-2: #7c5cff;
  --accent-soft: rgba(49, 198, 178, 0.18);
  --success: #58d68d;
  --success-soft: rgba(88, 214, 141, 0.14);
  --warning: #f4b740;
  --warning-soft: rgba(244, 183, 64, 0.14);
  --danger: #ff647c;
  --danger-soft: rgba(255, 100, 124, 0.14);
  --shadow: 0 20px 54px rgba(0, 0, 0, 0.24);
}

body {
  background: #0b0f17;
}

body::before {
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
}

.app-shell {
  grid-template-columns: 304px minmax(0, 1fr);
  background: transparent;
}

.sidebar {
  background: #0e1420;
  border-right: 1px solid var(--border);
  box-shadow: none;
}

.workspace {
  padding: 30px;
}

.topbar {
  padding: 4px 0 2px;
}

.topbar h1 {
  font-size: 32px;
  font-weight: 850;
}

.topbar p {
  color: var(--muted);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  background: rgba(18, 24, 36, 0.88);
  backdrop-filter: blur(16px);
}

.tab.is-active,
.primary-button,
.login-panel button,
.presence-form button,
.config-form button,
.control-form button[type="submit"],
.embed-builder button[type="submit"] {
  background: var(--accent);
  color: #061210;
  box-shadow: none;
}

.danger-button {
  background: var(--danger);
  color: #1d050a;
  box-shadow: none;
}

.secondary-button,
.icon-button {
  background: rgba(255, 255, 255, 0.055);
}

.secondary-button:hover,
.icon-button:hover {
  border-color: var(--accent);
  background: rgba(49, 198, 178, 0.12);
}

.stat-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.stat-card,
.panel,
.server-header,
.action-bar,
.modal-panel,
.login-panel {
  border-color: var(--border);
  background: linear-gradient(180deg, rgba(22, 30, 44, 0.98), rgba(16, 22, 33, 0.98));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

.stat-card {
  position: relative;
  min-height: 118px;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

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

.panel-head h2 {
  color: var(--text);
  font-size: 15px;
  font-weight: 850;
}

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

.command-center {
  padding: 18px;
}

.commands-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  gap: 18px;
  align-items: center;
  padding: 22px;
}

.commands-hero h2 {
  margin: 0 0 8px;
  font-size: 28px;
  color: var(--text);
}

.commands-hero p {
  margin: 0;
  color: var(--muted);
}

.commands-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
}

.command-category-list {
  position: sticky;
  top: 76px;
  align-self: start;
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 104px);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(22, 30, 44, 0.98), rgba(16, 22, 33, 0.98));
}

.command-category {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 68px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.command-category:hover,
.command-category.is-active {
  border-color: rgba(49, 198, 178, 0.46);
  background: rgba(49, 198, 178, 0.1);
}

.command-category strong,
.command-category small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-category small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.command-category b {
  display: grid;
  min-width: 34px;
  min-height: 30px;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent);
  font-size: 12px;
}

.command-catalog {
  display: grid;
  gap: 14px;
}

.command-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.command-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.command-section-head strong {
  color: var(--text);
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.command-card {
  position: relative;
  display: grid;
  gap: 6px;
  align-content: start;
  min-height: 136px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101722;
  color: var(--text);
  text-align: left;
}

.command-card:hover {
  border-color: rgba(49, 198, 178, 0.62);
  background: #142033;
}

.command-card strong,
.command-card span,
.command-card small {
  overflow-wrap: anywhere;
}

.command-card strong {
  color: #ffffff;
  font-size: 15px;
}

.command-card > span:not(.command-source),
.command-card small {
  color: var(--muted);
  font-size: 12px;
}

.command-card em {
  align-self: end;
  color: #c8d2df;
  font-size: 12px;
  font-style: normal;
}

.command-source {
  justify-self: start;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.075);
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.command-stats {
  margin-top: 0;
}

.compact-stats {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.compact-stats .stat-card {
  min-height: 96px;
}

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

.ticket-form label,
.field-block {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.field-block > span {
  color: var(--muted);
}

.segmented-control {
  display: grid;
  grid-auto-flow: column;
  gap: 4px;
  min-height: 40px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.segmented-control button {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.segmented-control button.is-active {
  background: var(--accent);
  color: #061210;
}

.state-chip {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

button.state-chip {
  cursor: pointer;
}

.state-chip.is-on {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(88, 214, 141, 0.22);
}

.state-chip.is-off {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border-color: var(--border);
}

.state-chip.is-warn {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: rgba(244, 183, 64, 0.22);
}

.ticket-panel-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101722;
}

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

.ticket-panel-row strong,
.ticket-panel-row span,
.ticket-panel-row small {
  display: block;
  overflow-wrap: anywhere;
}

.ticket-panel-row span,
.ticket-panel-row small {
  color: var(--muted);
}

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

.tickets-workspace {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.72fr);
}

.ticket-list-section {
  display: grid;
  gap: 6px;
}

.ticket-list-section + .ticket-list-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.list-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.config-cell {
  align-items: center;
}

.config-choice-panel {
  display: grid;
  gap: 5px;
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(56, 189, 248, 0.09), rgba(52, 211, 153, 0.06)),
    rgba(255, 255, 255, 0.04);
}

.config-choice-panel span,
.config-choice-panel small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.config-choice-panel strong {
  color: var(--text);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.config-choice-label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.config-choice-label strong {
  color: var(--text);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.config-cell .secondary-button {
  width: auto;
  min-width: 96px;
}

.config-form .segmented-control {
  margin: 0;
}

.switch-row {
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 74px;
  background: #101722;
}

.switch-row input {
  width: 54px;
  height: 30px;
  min-height: 30px;
}

.switch-row input::after {
  width: 24px;
  height: 24px;
}

.switch-row input:checked {
  background: var(--accent);
}

.switch-row input:checked::after {
  transform: translateX(24px);
}

.data-row,
.owner-server-row {
  border-color: var(--border);
}

.table-wrap {
  border-color: var(--border);
}

.modal-panel {
  overflow: hidden;
}

#pickerOverlay .modal-panel {
  grid-template-rows: auto auto minmax(88px, 1fr) auto;
}

#pickerOverlay .picker-list {
  min-height: 88px;
}

#pickerOverlay .modal-actions {
  align-items: center;
  flex-direction: row;
  justify-content: end;
  flex-shrink: 0;
}

#pickerOverlay .modal-actions button {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
}

th {
  background: #182233;
}

input,
select,
textarea {
  background: #0d1420;
}

@media (max-width: 1180px) {
  .ticket-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-grid,
  .compact-stats,
  .commands-hero,
  .commands-layout,
  .tickets-workspace {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .command-category-list {
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 18px;
  }

  .ticket-form,
  .command-grid,
  .ticket-panel-row,
  .commands-hero,
  .commands-layout,
  .compact-stats,
  .tickets-workspace {
    grid-template-columns: 1fr;
  }

  .ticket-row-actions,
  .panel-actions {
    justify-content: start;
  }

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

  .embed-preview-panel {
    position: static;
  }

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

  .discord-embed-thumbnail {
    width: 100%;
    height: auto;
    max-height: 180px;
  }
}

/* Executive dashboard finish */
.topbar,
.tabs,
.panel,
.stat-card,
.server-header,
.action-bar,
.ticket-panel-row,
.command-card,
.mini-card {
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.topbar {
  min-height: 74px;
}

.topbar .toolbar {
  align-items: center;
}

.panel:hover,
.stat-card:hover,
.server-header:hover,
.ticket-panel-row:hover,
.command-card:hover,
.mini-card:hover {
  border-color: rgba(49, 198, 178, 0.34);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
}

.stat-card:hover,
.command-card:hover,
.ticket-panel-row:hover {
  transform: translateY(-1px);
}

.stat-card span,
.mini-card span,
.list-kicker,
.panel-head .muted {
  letter-spacing: 0;
}

.stat-card span,
.mini-card span {
  text-transform: uppercase;
}

.tabs {
  border-radius: 8px;
}

.tab {
  transition: color 140ms ease, background 140ms ease;
}

.tab:not(.is-active):hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.table-wrap {
  background: rgba(12, 18, 31, 0.52);
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover td {
  background: rgba(49, 198, 178, 0.055);
}

.config-choice-panel {
  border-color: rgba(49, 198, 178, 0.22);
}

.config-choice-label .state-chip.is-off {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: rgba(244, 183, 64, 0.28);
}

.config-choice-label strong {
  font-size: 14px;
}

.config-cell .secondary-button,
.ticket-row-actions .secondary-button,
.panel-actions .secondary-button,
.json-actions .secondary-button {
  min-height: 34px;
}

.empty-state {
  border-color: rgba(154, 170, 203, 0.24);
  background: rgba(255, 255, 255, 0.035);
}

.guild-item,
.picker-option,
.switch-row,
.builder-row {
  transition: border-color 140ms ease, background 140ms ease;
}

.guild-item:hover,
.picker-option:hover,
.switch-row:hover,
.builder-row:hover {
  border-color: rgba(49, 198, 178, 0.3);
}

.setup-editor-head {
  border-color: rgba(49, 198, 178, 0.28);
  background: linear-gradient(135deg, rgba(49, 91, 234, 0.14), rgba(49, 198, 178, 0.08));
}

.setup-editor-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-color: rgba(154, 170, 203, 0.22);
  background: rgba(12, 18, 31, 0.46);
}

.setup-feature-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(154, 170, 203, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.setup-feature-title {
  display: grid;
  grid-column: 1 / -1;
  gap: 4px;
}

.setup-feature-title strong {
  color: var(--text);
}

.setup-feature-title span {
  color: var(--muted);
  font-size: 13px;
}

.setup-feature-card .token-row {
  grid-column: 1 / -1;
}

.token-row {
  align-items: center;
}

.config-form button.token-button {
  border-color: rgba(49, 198, 178, 0.28);
  background: rgba(49, 198, 178, 0.08);
  color: #a8fff2;
}

.config-form button.token-button:hover {
  background: rgba(49, 198, 178, 0.16);
}

@media (max-width: 760px) {
  .setup-editor-grid,
  .setup-feature-card {
    grid-template-columns: 1fr;
  }
}

/* SWAT command dashboard theme */
:root {
  --bg: #070a0f;
  --surface: rgba(14, 20, 31, 0.94);
  --surface-2: rgba(22, 31, 45, 0.92);
  --surface-3: #243246;
  --border: rgba(173, 194, 224, 0.16);
  --text: #f3f7fb;
  --muted: #9fb0c4;
  --accent: #26d9c4;
  --accent-2: #4f8cff;
  --accent-soft: rgba(38, 217, 196, 0.16);
  --success: #48db8f;
  --success-soft: rgba(72, 219, 143, 0.14);
  --warning: #f7bd3f;
  --warning-soft: rgba(247, 189, 63, 0.15);
  --danger: #ff5d73;
  --danger-soft: rgba(255, 93, 115, 0.15);
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.34);
}

html {
  background: #070a0f;
}

body {
  background:
    linear-gradient(145deg, rgba(79, 140, 255, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(38, 217, 196, 0.12), transparent 38%),
    linear-gradient(180deg, #090d14 0%, #101724 52%, #080b11 100%);
  color: var(--text);
  letter-spacing: 0;
}

body::before {
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(38, 217, 196, 0.06) 1px, transparent 1px);
  background-size: 48px 48px, 48px 48px, 192px 192px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.06));
}

button,
input,
select,
textarea {
  letter-spacing: 0;
}

.app-shell {
  grid-template-columns: 312px minmax(0, 1fr);
  background: rgba(5, 8, 14, 0.28);
}

.sidebar {
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(16, 25, 39, 0.98), rgba(7, 11, 18, 0.98)),
    #0b111b;
  border-right: 1px solid rgba(173, 194, 224, 0.16);
  box-shadow: 18px 0 46px rgba(0, 0, 0, 0.28);
}

.brand {
  padding: 10px;
  border: 1px solid rgba(173, 194, 224, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.login-mark,
.avatar {
  background: linear-gradient(135deg, #26d9c4, #4f8cff 56%, #8e66ff);
  box-shadow: 0 12px 28px rgba(38, 217, 196, 0.22);
}

.workspace {
  padding: 34px;
}

.topbar {
  margin-bottom: 20px;
  padding: 0 0 6px;
}

.topbar h1 {
  color: #ffffff;
  font-size: 32px;
  font-weight: 900;
}

.topbar p {
  color: #b4c2d6;
}

.toolbar {
  align-items: center;
}

.login-panel,
.stat-card,
.panel,
.server-header,
.action-bar,
.tabs,
.modal-panel,
.command-category-list {
  border: 1px solid rgba(173, 194, 224, 0.16);
  background:
    linear-gradient(180deg, rgba(24, 34, 49, 0.96), rgba(13, 19, 30, 0.96)),
    var(--surface);
  box-shadow: var(--shadow);
}

.login-panel,
.stat-card,
.panel,
.server-header,
.action-bar,
.tabs,
.modal-panel,
.guild-item,
.switch-row,
.control-card,
.mini-card,
.picker-option,
.builder-section,
.builder-row,
.setting-editor-grid,
.custom-editor-head,
.config-editor-row,
.role-reward-row,
.command-section,
.command-card,
.empty-state {
  border-radius: 8px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 8;
  gap: 7px;
  padding: 7px;
  background: rgba(9, 14, 23, 0.82);
  backdrop-filter: blur(18px);
}

.tab {
  min-height: 38px;
  color: #aebdd0;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.tab.is-active {
  background: linear-gradient(135deg, #26d9c4, #4f8cff);
  color: #04110f;
}

.primary-button,
.login-panel button,
.presence-form button,
.config-form button,
.control-form button[type="submit"],
.embed-builder button[type="submit"] {
  background: linear-gradient(135deg, #26d9c4, #4f8cff);
  color: #03110f;
  box-shadow: 0 12px 30px rgba(38, 217, 196, 0.18);
}

.danger-button {
  background: linear-gradient(135deg, #ff5d73, #f7bd3f);
  color: #220407;
}

.secondary-button,
.icon-button {
  border-color: rgba(173, 194, 224, 0.18);
  background: rgba(255, 255, 255, 0.055);
  color: #dce7f5;
}

.secondary-button:hover,
.icon-button:hover {
  border-color: rgba(38, 217, 196, 0.58);
  background: rgba(38, 217, 196, 0.12);
  color: #ffffff;
}

input,
select,
textarea {
  border-color: rgba(173, 194, 224, 0.18);
  background: rgba(5, 9, 16, 0.74);
  color: #f5f8fc;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(38, 217, 196, 0.78);
  box-shadow: 0 0 0 3px rgba(38, 217, 196, 0.16);
}

input::placeholder,
textarea::placeholder {
  color: #748399;
}

.guild-list {
  gap: 10px;
}

.guild-item {
  border-color: rgba(173, 194, 224, 0.12);
  background: rgba(255, 255, 255, 0.035);
}

.guild-item:hover,
.guild-item.is-active {
  border-color: rgba(38, 217, 196, 0.46);
  background: linear-gradient(135deg, rgba(38, 217, 196, 0.13), rgba(79, 140, 255, 0.1));
}

.pill {
  background: rgba(72, 219, 143, 0.16);
  color: #74f2ad;
}

.pill.warn {
  background: rgba(247, 189, 63, 0.16);
  color: #ffd67a;
}

.pill.danger {
  background: rgba(255, 93, 115, 0.16);
  color: #ff91a0;
}

.stat-grid {
  gap: 16px;
}

.stat-card {
  min-height: 126px;
  background:
    linear-gradient(135deg, rgba(38, 217, 196, 0.1), transparent 42%),
    linear-gradient(180deg, rgba(25, 36, 52, 0.98), rgba(13, 19, 30, 0.98));
}

.stat-card::after {
  right: 16px;
  bottom: 16px;
  width: 54px;
  height: 5px;
  background: linear-gradient(90deg, #26d9c4, #4f8cff, #f7bd3f);
}

.stat-card span,
.panel-head .muted,
.muted,
.data-row span,
.data-row small,
.owner-server-row span,
.control-card p,
.mini-card span {
  color: #9fb0c4;
}

.stat-card strong,
.mini-card strong,
.server-header h2,
.panel h2,
.panel-head h2,
.command-section-head strong {
  color: #ffffff;
}

.panel-head {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(173, 194, 224, 0.11);
}

.switch-row,
.control-card,
.mini-card,
.picker-option,
.builder-section,
.builder-row,
.setting-editor-grid,
.custom-editor-head,
.config-editor-row,
.role-reward-row,
.command-section,
.command-card,
.empty-state {
  border-color: rgba(173, 194, 224, 0.14);
  background: rgba(255, 255, 255, 0.045);
}

.switch-row:hover,
.picker-option:hover,
.builder-row:hover,
.command-card:hover,
.command-category:hover,
.command-category.is-active {
  border-color: rgba(38, 217, 196, 0.48);
  background: rgba(38, 217, 196, 0.09);
}

.switch-row input {
  background: #39475b;
}

.switch-row input:checked {
  background: linear-gradient(135deg, #48db8f, #26d9c4);
}

.table-wrap,
th,
td,
.data-row,
.owner-server-row {
  border-color: rgba(173, 194, 224, 0.12);
}

th {
  background: rgba(10, 15, 24, 0.96);
  color: #c8d4e3;
}

tbody tr:hover td {
  background: rgba(38, 217, 196, 0.045);
}

.bar-track,
.empty-state,
.muted-swatch {
  background: rgba(255, 255, 255, 0.065);
}

.bar-fill {
  background: linear-gradient(90deg, #26d9c4, #4f8cff, #48db8f);
}

.embed-builder,
.embed-preview-panel {
  border-color: rgba(173, 194, 224, 0.16);
  background:
    linear-gradient(180deg, rgba(18, 28, 43, 0.96), rgba(9, 14, 23, 0.96)),
    #0f1622;
}

.discord-preview {
  border-color: rgba(255, 255, 255, 0.12);
  background: #2b2d31;
}

.config-form button.token-button {
  border-color: rgba(38, 217, 196, 0.32);
  background: rgba(38, 217, 196, 0.1);
  color: #a8fff2;
}

.setup-editor-head {
  border-color: rgba(38, 217, 196, 0.32);
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.16), rgba(38, 217, 196, 0.1));
}

.toast {
  border-color: rgba(38, 217, 196, 0.24);
  background: #0d1420;
  box-shadow: var(--shadow);
}

.modal-overlay {
  background: rgba(3, 6, 11, 0.78);
  backdrop-filter: blur(10px);
}

@media (max-width: 860px) {
  .workspace {
    padding: 22px;
  }

  .sidebar {
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
  }

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

@media (max-width: 520px) {
  .workspace {
    padding: 14px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .tab {
    min-height: 40px;
  }
}

/* Overview command deck */
.ops-deck {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.4fr) minmax(220px, 0.42fr);
  gap: 16px;
  align-items: stretch;
  padding: 18px 0 20px;
  border-top: 1px solid rgba(173, 194, 224, 0.14);
  border-bottom: 1px solid rgba(173, 194, 224, 0.14);
}

.ops-deck-copy {
  display: grid;
  align-content: center;
  gap: 7px;
  min-width: 0;
}

.deck-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.ops-deck h2 {
  margin: 0;
  color: #ffffff;
  font-size: 22px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.ops-deck p {
  margin: 0;
  color: #aebdd0;
  overflow-wrap: anywhere;
}

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

.insight-card {
  position: relative;
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 112px;
  padding: 14px 14px 14px 16px;
  overflow: hidden;
  border: 1px solid rgba(173, 194, 224, 0.15);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    rgba(10, 16, 26, 0.82);
}

.insight-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.insight-card.is-good::before {
  background: var(--success);
}

.insight-card.is-warn::before {
  background: var(--warning);
}

.insight-card.is-danger::before {
  background: var(--danger);
}

.insight-card span {
  color: #93a5ba;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.insight-card strong {
  color: #ffffff;
  font-size: 18px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.insight-card small {
  color: #aebdd0;
  overflow-wrap: anywhere;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-content: center;
}

.quick-action {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(173, 194, 224, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: #e8f0f8;
  font-weight: 850;
}

.quick-action:hover {
  border-color: rgba(38, 217, 196, 0.52);
  background: rgba(38, 217, 196, 0.12);
  color: #ffffff;
}

.guild-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 66px;
}

.guild-identity {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.guild-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(173, 194, 224, 0.16);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(38, 217, 196, 0.28), rgba(79, 140, 255, 0.26));
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
}

.guild-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.guild-copy {
  min-width: 0;
}

.guild-copy strong,
.guild-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guild-copy small {
  margin-top: 3px;
}

@media (max-width: 1280px) {
  .ops-deck {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 860px) {
  .insight-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .ops-deck {
    gap: 12px;
    padding: 14px 0;
  }

  .insight-strip,
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .insight-card {
    min-height: 92px;
  }
}

/* Keep the final theme layer responsive. */
@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    grid-template-rows: auto auto auto auto;
    border-right: 0;
    border-bottom: 1px solid rgba(173, 194, 224, 0.16);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
  }

  .guild-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(240px, 1fr);
    overflow-x: auto;
    overflow-y: hidden;
  }

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

  .toolbar {
    width: 100%;
  }

  .toolbar .secondary-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .guild-list {
    grid-auto-columns: minmax(220px, 86vw);
  }
}

/* Premium SaaS dashboard pass */
:root {
  --bg: #0b1020;
  --page: #0f1524;
  --sidebar: #0c1220;
  --surface: #151b2b;
  --surface-2: #111827;
  --surface-3: #1b2436;
  --surface-hover: #202a40;
  --border: rgba(203, 213, 225, 0.12);
  --border-strong: rgba(203, 213, 225, 0.2);
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-strong: #cbd5e1;
  --accent: #5865f2;
  --accent-2: #1fb6ff;
  --accent-soft: rgba(88, 101, 242, 0.18);
  --success: #3ddc97;
  --success-soft: rgba(61, 220, 151, 0.14);
  --warning: #f0b232;
  --warning-soft: rgba(240, 178, 50, 0.14);
  --danger: #ff6680;
  --danger-soft: rgba(255, 102, 128, 0.14);
  --shadow: 0 18px 45px rgba(2, 6, 23, 0.26);
}

html {
  background: var(--bg);
}

body {
  background:
    linear-gradient(180deg, #10172a 0%, #0b1020 46%, #0b1020 100%);
  color: var(--text);
  font-size: 14px;
}

body::before {
  opacity: 0.2;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 76%);
}

.app-shell {
  position: relative;
  grid-template-columns: 288px minmax(0, 1fr);
  min-height: 100vh;
  background: transparent;
  transition: grid-template-columns 180ms ease;
}

.app-shell:has(.sidebar-toggle-input:checked) {
  grid-template-columns: 86px minmax(0, 1fr);
}

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 14px;
  height: 100vh;
  padding: 16px;
  border-right: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(12, 18, 32, 0.96)),
    var(--sidebar);
  box-shadow: none;
}

.brand {
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  gap: 10px;
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.035);
}

.brand-copy strong {
  color: var(--text);
  font-size: 14px;
}

.brand-copy span {
  color: var(--muted);
  font-size: 12px;
}

.avatar,
.login-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 28px rgba(88, 101, 242, 0.22);
}

.sidebar-toggle-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  align-self: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.sidebar-toggle-button span,
.sidebar-toggle-button span::before,
.sidebar-toggle-button span::after {
  display: block;
  width: 14px;
  height: 2px;
  border-radius: 999px;
  background: var(--muted-strong);
  content: "";
}

.sidebar-toggle-button span::before {
  transform: translateY(-5px);
}

.sidebar-toggle-button span::after {
  transform: translateY(3px);
}

.sidebar-toggle-button:hover {
  border-color: rgba(88, 101, 242, 0.6);
  background: var(--accent-soft);
}

.app-shell:has(.sidebar-toggle-input:checked) .brand {
  grid-template-columns: 42px;
  justify-content: center;
  padding: 8px 5px;
}

.app-shell:has(.sidebar-toggle-input:checked) .brand-copy,
.app-shell:has(.sidebar-toggle-input:checked) .search-box,
.app-shell:has(.sidebar-toggle-input:checked) .guild-copy,
.app-shell:has(.sidebar-toggle-input:checked) .guild-item .pill,
.app-shell:has(.sidebar-toggle-input:checked) #logoutButton {
  display: none;
}

.app-shell:has(.sidebar-toggle-input:checked) .sidebar-toggle-button {
  grid-row: 2;
  justify-self: center;
}

.sidebar-nav.tabs {
  position: static;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.tab {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 4px 10px 4px 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 760;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.045);
  color: #ffffff;
  transform: translateX(1px);
}

.tab.is-active {
  border-color: rgba(88, 101, 242, 0.45);
  background: linear-gradient(135deg, rgba(88, 101, 242, 0.22), rgba(31, 182, 255, 0.1));
  color: #ffffff;
}

.tab.is-active .tab-icon {
  border-color: rgba(88, 101, 242, 0.45);
  background: var(--accent);
  color: #ffffff;
}

.app-shell:has(.sidebar-toggle-input:checked) .sidebar {
  padding: 16px 10px;
}

.app-shell:has(.sidebar-toggle-input:checked) .sidebar-nav.tabs {
  justify-items: center;
}

.app-shell:has(.sidebar-toggle-input:checked) .tab {
  grid-template-columns: 34px;
  width: 42px;
  padding: 4px;
}

.app-shell:has(.sidebar-toggle-input:checked) .tab-label {
  display: none;
}

.app-shell:has(.sidebar-toggle-input:checked) .guild-list {
  justify-items: center;
}

.app-shell:has(.sidebar-toggle-input:checked) .guild-item {
  width: 46px;
  min-height: 46px;
  grid-template-columns: 1fr;
  padding: 4px;
}

.app-shell:has(.sidebar-toggle-input:checked) .guild-identity {
  grid-template-columns: 38px;
}

.workspace {
  max-width: 1680px;
  width: 100%;
  padding: 28px 32px 44px;
}

.topbar {
  min-height: auto;
  margin-bottom: 22px;
  padding: 0;
}

.topbar h1 {
  color: var(--text);
  font-size: 28px;
  font-weight: 780;
}

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

.toolbar .secondary-button,
.secondary-button,
.primary-button,
.danger-button,
.login-panel button,
.presence-form button,
.config-form button,
.control-form button[type="submit"],
.embed-builder button[type="submit"] {
  min-height: 38px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 760;
}

.primary-button,
.login-panel button,
.presence-form button,
.config-form button,
.control-form button[type="submit"],
.embed-builder button[type="submit"] {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(88, 101, 242, 0.18);
}

.danger-button {
  background: var(--danger);
  color: #18050a;
}

.secondary-button,
.icon-button,
.quick-action {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted-strong);
  box-shadow: none;
}

.secondary-button:hover,
.icon-button:hover,
.quick-action:hover {
  border-color: rgba(88, 101, 242, 0.48);
  background: var(--accent-soft);
  color: #ffffff;
}

.search-box label,
.presence-form label,
.config-form label,
.control-form label,
.embed-builder label,
.ticket-form label,
.field-block {
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 720;
}

input,
select,
textarea {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.74);
  color: var(--text);
  padding: 9px 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
  background: rgba(15, 23, 42, 0.92);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(88, 101, 242, 0.85);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.18);
}

input::placeholder,
textarea::placeholder {
  color: #64748b;
}

.panel,
.stat-card,
.server-header,
.action-bar,
.modal-panel,
.login-panel,
.ticket-panel-row,
.command-section,
.command-card,
.mini-card,
.control-card,
.builder-section,
.builder-row,
.setting-editor-grid,
.custom-editor-head,
.config-editor-row,
.role-reward-row,
.picker-option,
.empty-state {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(21, 27, 43, 0.9);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035);
}

.panel:hover,
.stat-card:hover,
.server-header:hover,
.ticket-panel-row:hover,
.command-card:hover,
.mini-card:hover {
  border-color: rgba(203, 213, 225, 0.2);
  box-shadow: 0 14px 34px rgba(2, 6, 23, 0.2);
}

.panel {
  padding: 18px;
}

.panel-head {
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.panel h2,
.panel-head h2 {
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
  text-transform: none;
}

.stat-grid {
  gap: 14px;
}

.stat-card {
  min-height: 112px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
    rgba(21, 27, 43, 0.92);
}

.stat-card::after {
  width: 34px;
  height: 3px;
  background: var(--accent);
}

.stat-card span,
.mini-card span,
.insight-card span,
.list-kicker,
.config-choice-panel span,
.config-choice-panel small {
  color: var(--muted);
  letter-spacing: 0;
}

.stat-card strong {
  margin-top: 9px;
  color: var(--text);
  font-size: 28px;
  font-weight: 780;
}

.stat-card small,
.data-row span,
.data-row small,
.owner-server-row span,
.ticket-panel-row span,
.ticket-panel-row small {
  color: var(--muted);
}

.ops-deck {
  gap: 18px;
  margin-bottom: 2px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(88, 101, 242, 0.14), rgba(31, 182, 255, 0.06)),
    rgba(21, 27, 43, 0.82);
}

.deck-kicker {
  color: #8ea2ff;
}

.insight-card {
  border-color: rgba(203, 213, 225, 0.13);
  background: rgba(15, 23, 42, 0.55);
}

.quick-actions {
  align-content: stretch;
}

.quick-action {
  min-height: 42px;
}

.guild-list {
  gap: 8px;
  padding-right: 0;
}

.guild-item {
  min-height: 60px;
  padding: 8px;
  border-color: transparent;
  background: transparent;
}

.guild-item:hover,
.guild-item.is-active {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.045);
}

.guild-icon {
  border-color: var(--border);
  background: rgba(88, 101, 242, 0.16);
}

.pill,
.state-chip {
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 760;
}

.switch-row {
  min-height: 70px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.56);
}

.switch-row input {
  width: 48px;
  height: 28px;
  min-height: 28px;
  background: #334155;
}

.switch-row input::after {
  width: 22px;
  height: 22px;
}

.switch-row input:checked {
  background: var(--accent);
}

.switch-row input:checked::after {
  transform: translateX(20px);
}

.content-grid,
.server-control-grid,
.embed-workbench,
.commands-layout,
.tickets-workspace {
  gap: 16px;
}

.table-wrap {
  border-color: var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.44);
}

th {
  background: rgba(15, 23, 42, 0.96);
  color: var(--muted-strong);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  color: var(--muted-strong);
}

th,
td {
  padding: 12px 14px;
  border-color: var(--border);
}

tbody tr:hover td {
  background: rgba(88, 101, 242, 0.06);
}

.data-row {
  min-height: 58px;
  padding: 12px 0;
  border-color: var(--border);
}

.data-row strong,
.ticket-panel-row strong,
.command-card strong {
  color: var(--text);
  font-weight: 760;
}

.empty-state {
  min-height: 88px;
  border-style: dashed;
  border-color: var(--border-strong);
  background: rgba(15, 23, 42, 0.42);
  color: var(--muted);
}

.error-banner {
  border-color: rgba(255, 102, 128, 0.28);
  background: rgba(255, 102, 128, 0.12);
  color: #ffc2cc;
  box-shadow: none;
}

.toast {
  border-color: rgba(203, 213, 225, 0.18);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: var(--shadow);
}

.modal-overlay {
  background: rgba(2, 6, 23, 0.76);
  backdrop-filter: blur(12px);
}

.modal-panel {
  background: rgba(21, 27, 43, 0.98);
}

.segmented-control {
  border-color: var(--border);
  background: rgba(15, 23, 42, 0.64);
}

.segmented-control button {
  color: var(--muted-strong);
}

.segmented-control button.is-active {
  background: var(--accent);
  color: #ffffff;
}

.embed-builder,
.embed-preview-panel {
  border-color: var(--border);
  background: rgba(15, 23, 42, 0.7);
}

.discord-preview {
  border-color: rgba(255, 255, 255, 0.12);
}

.command-category-list {
  border-color: var(--border);
  background: rgba(21, 27, 43, 0.9);
}

.command-category {
  border-radius: 8px;
}

.command-category:hover,
.command-category.is-active {
  border-color: rgba(88, 101, 242, 0.44);
  background: var(--accent-soft);
}

.command-card {
  background: rgba(15, 23, 42, 0.62);
}

.command-card:hover {
  background: rgba(30, 41, 59, 0.76);
}

.command-source {
  background: rgba(88, 101, 242, 0.16);
  color: #b9c1ff;
}

.config-choice-panel {
  border-color: var(--border);
  background: rgba(15, 23, 42, 0.55);
}

.setup-editor-head,
.setup-feature-card {
  border-color: var(--border);
  background: rgba(15, 23, 42, 0.55);
}

@keyframes dashboardFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view:not(.is-hidden) {
  animation: dashboardFadeIn 180ms ease both;
}

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

  .app-shell:has(.sidebar-toggle-input:checked) {
    grid-template-columns: 86px minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .app-shell,
  .app-shell:has(.sidebar-toggle-input:checked) {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto auto auto auto auto;
    padding: 14px;
  }

  .sidebar-toggle-button {
    display: none;
  }

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

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

  .tab {
    grid-template-columns: 30px minmax(0, 1fr);
    min-height: 40px;
  }

  .tab-icon {
    width: 28px;
    height: 28px;
  }

  .workspace {
    padding: 22px;
  }

  .guild-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(230px, 280px);
    overflow-x: auto;
    overflow-y: hidden;
  }
}

@media (max-width: 560px) {
  .sidebar-nav.tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    padding: 16px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .ops-deck {
    padding: 16px;
  }

  .stat-card {
    min-height: 98px;
  }
}

#appView.app-shell:has(.sidebar-toggle-input:checked) {
  grid-template-columns: 86px minmax(0, 1fr);
}

@media (max-width: 860px) {
  #appView.app-shell:has(.sidebar-toggle-input:checked) {
    grid-template-columns: 1fr;
  }
}

/* Server workspace section tabs */
.server-section-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.68);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035);
}

.server-section-tab {
  display: grid;
  gap: 3px;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-strong);
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.server-section-tab span,
.server-section-tab small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-section-tab span {
  font-size: 13px;
  font-weight: 780;
}

.server-section-tab small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.server-section-tab:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.045);
  color: #ffffff;
  transform: translateY(-1px);
}

.server-section-tab.is-active {
  border-color: rgba(88, 101, 242, 0.46);
  background:
    linear-gradient(135deg, rgba(88, 101, 242, 0.24), rgba(31, 182, 255, 0.1)),
    rgba(15, 23, 42, 0.72);
  color: #ffffff;
}

.server-section-tab.is-active small {
  color: #c7d2fe;
}

.server-section-panel:not(.is-hidden) {
  animation: dashboardFadeIn 180ms ease both;
}

.settings-panel {
  padding: 0;
  overflow: hidden;
}

.settings-panel > .panel-head {
  margin: 0;
  padding: 18px 20px;
  background:
    linear-gradient(135deg, rgba(88, 101, 242, 0.1), rgba(31, 182, 255, 0.04)),
    rgba(15, 23, 42, 0.36);
}

.settings-workbench {
  display: grid;
  grid-template-columns: minmax(300px, 0.38fr) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.settings-editor-card,
.settings-table-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.56);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035);
}

.settings-editor-card {
  position: sticky;
  top: 18px;
  align-self: start;
  padding: 16px;
}

.settings-table-card {
  overflow: hidden;
}

.settings-table-head {
  display: grid;
  gap: 4px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
}

.settings-table-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
}

.settings-table-head strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
}

.settings-table-card .table-wrap {
  max-height: 680px;
  margin-top: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.settings-table-card table {
  table-layout: auto;
}

.settings-table-card th:first-child,
.settings-table-card td:first-child {
  width: 42%;
}

.settings-table-card tbody tr {
  transition: background 140ms ease;
}

.settings-table-card td {
  padding: 14px 16px;
}

.settings-table-card td strong {
  color: var(--text);
  font-size: 13px;
}

.settings-table-card .config-cell {
  grid-template-columns: minmax(0, 1fr) auto;
}

.settings-table-card .config-choice-label {
  gap: 8px;
}

.settings-table-card .config-choice-label strong {
  color: var(--muted-strong);
}

.settings-editor-card .config-form {
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.settings-editor-card .config-choice-panel {
  min-height: 98px;
}

.settings-editor-card .config-form button[type="submit"] {
  min-height: 42px;
}

.settings-section .config-custom-editor {
  max-height: 520px;
  overflow: auto;
  padding-right: 2px;
}

.command-access-panel {
  padding: 0;
  overflow: hidden;
}

.command-access-panel > .panel-head {
  margin: 0;
  padding: 18px 20px;
  background:
    linear-gradient(135deg, rgba(88, 101, 242, 0.12), rgba(16, 185, 129, 0.05)),
    rgba(15, 23, 42, 0.34);
}

.command-access-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.32fr) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  padding: 18px;
}

.command-access-sidebar,
.command-access-editor-shell {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.54);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035);
}

.command-access-sidebar {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px;
}

.command-access-sidebar label,
.command-access-search {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.command-access-role-list {
  display: grid;
  gap: 8px;
  max-height: 580px;
  overflow: auto;
  padding-right: 2px;
}

.command-access-role {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 62px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.028);
  color: var(--text);
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.command-access-role:hover,
.command-access-role.is-active {
  border-color: rgba(88, 101, 242, 0.45);
  background: rgba(88, 101, 242, 0.11);
  transform: translateY(-1px);
}

.command-access-role span {
  min-width: 0;
}

.command-access-role strong,
.command-access-role small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-access-role small {
  color: var(--muted);
  font-size: 12px;
}

.command-access-role b {
  min-width: 34px;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted-strong);
  font-size: 12px;
  text-align: center;
}

.command-access-role.is-dirty b {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
}

.command-access-editor-shell {
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.command-access-toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
}

.command-access-search {
  flex: 1 1 360px;
}

.command-access-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.command-access-editor {
  display: grid;
  gap: 14px;
  max-height: 700px;
  overflow: auto;
  padding: 14px;
  align-content: start;
}

.command-access-section {
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(8, 13, 24, 0.24);
}

.command-access-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 840;
  text-transform: uppercase;
}

.command-access-section-head strong {
  color: #c7d2fe;
}

.command-access-command-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  grid-auto-rows: minmax(78px, auto);
  gap: 10px;
  padding: 12px;
}

.command-access-command {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 78px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.command-access-command:hover {
  border-color: rgba(148, 163, 184, 0.46);
  background: rgba(255, 255, 255, 0.055);
  transform: translateY(-1px);
}

.command-access-command.is-checked {
  border-color: rgba(88, 101, 242, 0.58);
  background:
    linear-gradient(135deg, rgba(88, 101, 242, 0.18), rgba(16, 185, 129, 0.06)),
    rgba(255, 255, 255, 0.035);
}

.command-access-command input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin-top: 2px;
  padding: 0;
  accent-color: #5865f2;
}

.command-access-command-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.command-access-command-main strong,
.command-access-command-main small {
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-access-command-main strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 820;
  white-space: normal;
  overflow-wrap: anywhere;
}

.command-access-command-main small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.command-access-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.command-access-tags em {
  padding: 2px 6px;
  border: 1px solid rgba(88, 101, 242, 0.28);
  border-radius: 6px;
  background: rgba(88, 101, 242, 0.12);
  color: #c7d2fe;
  font-size: 11px;
  font-style: normal;
  font-weight: 760;
}

.command-access-actions {
  justify-content: flex-end;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
}

.server-control-panel,
.command-access-panel,
.role-react-studio,
.server-section-panel[data-server-section-panel="embed"] {
  overflow: hidden;
}

.server-section-panel[data-server-section-panel="activity"].content-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1180px) {
  .server-section-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .settings-workbench,
  .command-access-layout,
  .server-section-panel[data-server-section-panel="activity"].content-grid.three {
    grid-template-columns: 1fr;
  }

  .settings-editor-card {
    position: static;
  }
}

@media (max-width: 640px) {
  .server-section-tabs {
    grid-template-columns: 1fr;
  }

  .server-section-tab {
    min-height: 48px;
  }

  .settings-workbench {
    padding: 14px;
  }

  .command-access-layout {
    padding: 14px;
  }

  .command-access-toolbar,
  .command-access-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .command-access-toolbar-actions,
  .command-access-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .settings-editor-card {
    padding: 14px;
  }

  .settings-editor-card .config-form,
  .settings-table-card .config-cell {
    grid-template-columns: 1fr;
  }

  .settings-table-card th:first-child,
  .settings-table-card td:first-child {
    width: auto;
  }
}

/* Final responsive dashboard layer */
@media (max-width: 900px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    min-width: 0;
  }

  #appView.app-shell,
  #appView.app-shell:has(.sidebar-toggle-input:checked),
  .app-shell,
  .app-shell:has(.sidebar-toggle-input:checked) {
    display: block;
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .sidebar {
    position: relative;
    top: auto;
    z-index: 15;
    height: auto;
    max-height: none;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand,
  .app-shell:has(.sidebar-toggle-input:checked) .brand {
    grid-template-columns: 42px minmax(0, 1fr);
    justify-content: stretch;
    padding: 8px;
  }

  .app-shell:has(.sidebar-toggle-input:checked) .brand-copy,
  .app-shell:has(.sidebar-toggle-input:checked) .search-box,
  .app-shell:has(.sidebar-toggle-input:checked) #logoutButton {
    display: grid;
  }

  .app-shell:has(.sidebar-toggle-input:checked) .guild-copy,
  .app-shell:has(.sidebar-toggle-input:checked) .guild-item .pill {
    display: block;
  }

  .sidebar-toggle-button {
    display: none;
  }

  .sidebar-nav.tabs,
  .app-shell:has(.sidebar-toggle-input:checked) .sidebar-nav.tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
  }

  .tab,
  .app-shell:has(.sidebar-toggle-input:checked) .tab {
    grid-template-columns: 30px max-content;
    flex: 0 0 auto;
    width: auto;
    min-width: 136px;
    padding: 5px 10px 5px 5px;
    scroll-snap-align: start;
  }

  .app-shell:has(.sidebar-toggle-input:checked) .tab-label {
    display: inline;
  }

  .guild-list,
  .app-shell:has(.sidebar-toggle-input:checked) .guild-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(232px, 82vw);
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
  }

  .guild-item,
  .app-shell:has(.sidebar-toggle-input:checked) .guild-item {
    width: auto;
    grid-template-columns: minmax(0, 1fr);
    min-height: 58px;
  }

  .guild-identity,
  .app-shell:has(.sidebar-toggle-input:checked) .guild-identity {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .workspace {
    max-width: none;
    padding: 18px 14px 32px;
  }

  .topbar,
  .panel-head,
  .settings-table-head,
  .command-access-panel > .panel-head {
    align-items: flex-start;
    gap: 10px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar,
  .panel-actions {
    width: 100%;
    justify-content: stretch;
  }

  .toolbar > *,
  .panel-actions > * {
    flex: 1 1 auto;
  }

  .ops-deck,
  .content-grid,
  .content-grid.three,
  .stat-grid,
  .mini-grid,
  .switch-grid,
  .server-control-grid,
  .embed-workbench,
  .tickets-workspace,
  .commands-layout,
  .settings-workbench,
  .setting-editor-grid,
  .config-editor-row,
  .role-reward-row,
  .invite-role-row,
  .builder-row,
  .ticket-form,
  .presence-form,
  .control-form,
  .embed-builder,
  .owner-grid {
    grid-template-columns: 1fr;
  }

  .server-section-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px;
    scroll-snap-type: x proximity;
  }

  .server-section-tab {
    flex: 0 0 42vw;
    min-width: 132px;
    max-width: 220px;
    scroll-snap-align: start;
  }

  .table-wrap,
  .settings-table-card .table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 560px;
  }

  .settings-table-card table {
    min-width: 620px;
  }

  .command-category-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px;
  }

  .command-category {
    flex: 0 0 72vw;
    min-width: 190px;
    max-width: 280px;
  }

  .command-grid,
  .command-access-command-grid {
    grid-template-columns: 1fr;
  }

  .modal-panel {
    width: min(100%, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 14px 10px 28px;
  }

  .panel,
  .server-header,
  .action-bar,
  .ops-deck {
    padding: 14px;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .topbar p,
  .server-header p {
    font-size: 12px;
  }

  .stat-card strong {
    font-size: 24px;
  }

  .server-header,
  .action-bar,
  .panel-head,
  .settings-table-head,
  .command-access-panel > .panel-head {
    grid-template-columns: 1fr;
  }

  .settings-panel,
  .command-access-panel,
  .role-react-studio,
  .server-control-panel,
  .server-section-panel[data-server-section-panel="embed"] {
    border-radius: 8px;
  }

  .settings-workbench,
  .command-access-layout {
    gap: 12px;
    padding: 12px;
  }

  .command-access-sidebar,
  .command-access-editor-shell,
  .settings-editor-card,
  .settings-table-card {
    border-radius: 8px;
  }

  .command-access-role-list {
    max-height: 260px;
  }

  .command-access-toolbar,
  .command-access-actions {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .command-access-toolbar-actions,
  .button-row,
  .panel-actions,
  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .command-access-editor {
    max-height: none;
  }

  .command-access-command {
    min-height: auto;
  }

  .command-access-command-main strong {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .embed-preview-panel {
    position: static;
  }

  .config-form button,
  .control-form button,
  .embed-builder button,
  .ticket-form button,
  .primary-button,
  .secondary-button,
  .danger-button {
    width: 100%;
  }

  .toast {
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
  }
}

@media (max-width: 420px) {
  .workspace {
    padding: 12px 8px 24px;
  }

  .sidebar {
    padding: 10px;
  }

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

  .avatar,
  .login-mark {
    width: 38px;
    height: 38px;
  }

  .tab {
    min-width: 118px;
  }

  .server-section-tab {
    min-width: 118px;
  }

  .panel,
  .server-header,
  .action-bar,
  .ops-deck,
  .settings-editor-card,
  .command-access-sidebar,
  .command-access-editor-shell {
    padding: 12px;
  }

  .settings-workbench,
  .command-access-layout {
    padding: 8px;
  }

  .command-access-role {
    min-height: 56px;
    padding: 10px;
  }

  .command-access-command {
    grid-template-columns: 22px minmax(0, 1fr);
    padding: 10px;
  }

  .login-panel {
    width: min(100%, calc(100vw - 20px));
    padding: 18px;
  }
}
