:root {
  color-scheme: dark;
  --bg: #090c12;
  --rail: #0d1119;
  --surface: #111620;
  --surface-2: #171d28;
  --line: #29303d;
  --text: #f5f7fb;
  --muted: #969ead;
  --purple: #63cfd1;
  --green: #62d69b;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-family: Inter, "Segoe UI", Arial, sans-serif; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.rail { position: fixed; inset: 0 auto 0 0; width: 64px; display: flex; flex-direction: column; align-items: center; gap: 12px; border-right: 1px solid #202633; background: var(--rail); z-index: 10; }
.rail-brand { width: 36px; height: 36px; display: grid; place-items: center; margin: 16px 0 22px; border-radius: 10px; background: rgba(99,207,209,.08); text-decoration: none; }
.rail-brand img { width: 34px; height: 34px; object-fit: contain; }
.rail-link { width: 40px; height: 40px; border: 0; border-radius: 9px; display: grid; place-items: center; background: transparent; color: #9199a8; text-decoration: none; cursor: pointer; }
.rail-link svg { width: 18px; height: 18px; fill: currentColor; }
.rail-link.active { color: #73d6d8; background: #17252a; }
.rail-link.active, .rail-link:hover { background: #17252a; color: #73d6d8; }
.dashboard-main { min-height: 100vh; margin-left: 64px; padding: 48px 44px 80px; }
.topbar, .server-header { min-height: 110px; display: flex; align-items: flex-start; justify-content: space-between; }
.eyebrow, .kicker { margin: 0 0 8px; color: #73d6d8; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(32px, 5vw, 48px); letter-spacing: -.045em; }
h2 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
h3 { margin: 0; }
.account { min-width: 170px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.account-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #2a3140; font-size: 11px; font-weight: 800; }
.account-avatar-image { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #2a3140; }
.account-name { color: #dfe3ea; font-size: 12px; }
.account button { border: 0; background: none; color: #858d9b; cursor: pointer; }
.account button svg { width: 18px; height: 18px; fill: currentColor; }
.toolbar { display: grid; grid-template-columns: auto minmax(220px, 260px); justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0 25px; }
.button { min-height: 40px; border: 0; border-radius: 8px; padding: 0 13px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: white; font-size: 12px; font-weight: 800; text-decoration: none; }
.button.primary { background: #56bfc2; }
.button.secondary { border: 1px solid #303744; background: #171c25; }
.search { width: 260px; height: 40px; display: grid; grid-template-columns: 18px minmax(0,1fr); align-items: center; gap: 8px; border: 1px solid #2b3240; border-radius: 8px; padding: 0 12px; background: #121722; color: #7f8796; justify-self: end; }
.search svg { width: 16px; height: 16px; fill: currentColor; }
.search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; padding: 0; }
.button svg { width: 16px; height: 16px; fill: currentColor; }
.server-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.server-card { min-height: 108px; display: flex; align-items: center; gap: 13px; border: 1px solid #252c39; border-radius: 12px; padding: 16px; background: #111620; color: inherit; text-decoration: none; transition: border-color .16s, transform .16s, background .16s; }
.server-card:hover { border-color: #4e476f; background: #151a25; transform: translateY(-2px); }
.server-icon { width: 48px; height: 48px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; background: #252c38; font-size: 13px; font-weight: 850; overflow: hidden; }
.server-icon img { width: 100%; height: 100%; object-fit: cover; }
.server-info { min-width: 0; }
.server-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.server-info span { display: block; margin-top: 7px; color: #858d9c; font-size: 11px; }
.server-info .managed { color: #72d5a2; }
.server-card.disabled { opacity: .58; }
.loading, .empty { grid-column: 1/-1; border: 1px dashed #303744; border-radius: 12px; padding: 60px 20px; text-align: center; color: #7d8491; }

.server-main { max-width: 1420px; }
.server-header { min-height: 100px; align-items: center; }
.server-header > div:nth-child(3) { margin-right: auto; }
.server-avatar { width: 54px; height: 54px; flex: 0 0 auto; display: grid; place-items: center; margin: 0 14px 0 18px; border-radius: 14px; background: #252c38; font-size: 16px; font-weight: 850; overflow: hidden; }
.server-avatar img { width: 100%; height: 100%; object-fit: cover; }
.back-link { color: #aeb4bf; font-size: 12px; text-decoration: none; }
.tabs { height: 48px; display: flex; align-items: flex-end; gap: 4px; border-bottom: 1px solid #282f3b; margin-bottom: 24px; }
.tabs button { height: 48px; border: 0; border-bottom: 2px solid transparent; background: none; padding: 0 16px; color: #9299a7; cursor: pointer; font-size: 12px; font-weight: 750; }
.tabs button.active { border-bottom-color: #63cfd1; color: white; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.summary-card { min-height: 120px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid #282f3b; border-radius: 12px; padding: 18px; background: #111620; }
.summary-card span { color: #9299a7; font-size: 12px; }
.summary-card strong { font-size: 38px; letter-spacing: -.05em; }
.content-card { border: 1px solid #282f3b; border-radius: 12px; padding: 22px; background: #111620; }
.card-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
label { display: flex; flex-direction: column; gap: 8px; color: #bbc1cc; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #303744; border-radius: 8px; outline: 0; background: #171c25; color: var(--text); padding: 10px 11px; font-size: 12px; }
textarea { resize: vertical; }
select[multiple] { min-height: 100px; }
.page-heading { min-height: 74px; display: flex; align-items: flex-start; justify-content: space-between; }
.panel-layout { display: grid; grid-template-columns: 260px 1fr; gap: 12px; }
.panel-list { display: flex; flex-direction: column; gap: 8px; }
.panel-item { width: 100%; min-height: 74px; border: 1px solid #29303d; border-radius: 10px; background: #111620; color: var(--text); padding: 12px; text-align: left; cursor: pointer; }
.panel-item.active { border-color: #675ca1; background: #171722; }
.panel-item strong { display: block; }
.panel-item span { display: block; margin-top: 6px; color: #8e96a4; font-size: 10px; }
.panel-editor { display: flex; flex-direction: column; gap: 16px; }
.toggle-row { flex-direction: row; align-items: center; justify-content: space-between; border: 1px solid #303744; border-radius: 8px; padding: 12px; }
.toggle-row span { display: flex; flex-direction: column; }
.toggle-row small { margin-top: 4px; color: #8f96a4; font-weight: 500; }
.toggle-row input { width: 38px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.muted { color: #969ead; font-size: 12px; line-height: 1.6; }
.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { border-bottom: 1px solid #292f3a; padding: 14px 10px; text-align: left; }
th { color: #969ead; font-size: 10px; text-transform: uppercase; }
td { color: #bdc3cd; }

.app-settings-card { display: grid; grid-template-columns: 1fr 1.4fr; align-items: center; gap: 28px; margin-bottom: 12px; }
.app-settings-card h2 { margin-bottom: 8px; }
.app-settings-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 10px; }
.app-settings-form input[readonly] { color: #9299a7; }
.role-editor-card { margin-top: 12px; }
.role-editor-list { display: flex; flex-direction: column; gap: 8px; }
.role-row { display: grid; grid-template-columns: 18px 1fr 54px auto; align-items: center; gap: 10px; border: 1px solid #303744; border-radius: 8px; padding: 8px; }
.role-swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--role-color); box-shadow: 0 0 10px color-mix(in srgb, var(--role-color) 55%, transparent); }
.role-row input[type="text"], .role-row .role-name { min-width: 0; }
.role-row .role-color { height: 38px; padding: 4px; cursor: pointer; }
.role-row .button { min-width: 64px; }
.embed-editor { border: 1px solid #303744; border-radius: 10px; padding: 16px; background: #0f131b; }
.embed-editor .card-heading { margin-bottom: 14px; }
.config-section { border: 1px solid #303744; border-radius: 10px; background: #111620; overflow: hidden; }
.config-section + .config-section { margin-top: 8px; }
.config-section summary { min-height: 64px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; padding: 12px 14px; }
.config-section summary::-webkit-details-marker { display: none; }
.config-section summary span { display: flex; flex-direction: column; gap: 4px; }
.config-section summary small { color: #858d9b; font-weight: 500; }
.config-section summary b { color: #aaa0dc; transition: transform .18s; }
.config-section[open] summary b { transform: rotate(180deg); }
.config-section-body { border-top: 1px solid #303744; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.panel-editor { gap: 8px; }
.embed-fields-heading { display: flex; align-items: center; justify-content: space-between; }
.embed-fields-heading div { display: flex; flex-direction: column; }
.embed-fields-heading small { color: #858d9b; margin-top: 3px; }
.embed-fields-list { display: flex; flex-direction: column; gap: 8px; }
.embed-field-row { display: grid; grid-template-columns: 1fr 1.4fr auto 34px; align-items: center; gap: 8px; border: 1px solid #303744; border-radius: 8px; padding: 8px; }
.embed-field-row textarea { resize: vertical; }
.inline-field { display: flex; flex-direction: row; align-items: center; gap: 5px; white-space: nowrap; }
.inline-field input { width: 16px; height: 16px; }
.remove-field { width: 34px; height: 34px; border: 0; border-radius: 7px; background: #242a35; color: #d8dce4; cursor: pointer; }
.modal-fields-list { display: flex; flex-direction: column; gap: 10px; }
.modal-field-row { display: flex; flex-direction: column; gap: 10px; border: 1px solid #303744; border-radius: 9px; padding: 12px; background: #131820; }
.modal-field-head { display: flex; align-items: center; gap: 8px; }
.modal-field-head .modal-field-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.remove-modal-field { width: 34px; height: 34px; flex: 0 0 auto; border: 0; border-radius: 7px; background: #242a35; color: #d8dce4; cursor: pointer; }

@media (max-width: 980px) {
  .server-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .panel-layout { grid-template-columns: 1fr; }
  .panel-list { display: grid; grid-template-columns: repeat(2, 1fr); }
  .app-settings-card { grid-template-columns: 1fr; }
  .app-settings-form { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .rail { width: 52px; }
  .dashboard-main { margin-left: 52px; padding: 28px 16px 60px; }
  .server-grid, .summary-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr; align-items: stretch; gap: 8px; }
  .toolbar .button { width: 100%; }
  .search { width: 100%; justify-self: stretch; }
  .topbar, .server-header { min-height: 130px; }
  .account { min-width: 0; }
  .account-name { display: none; }
  .tabs { overflow-x: auto; }
  .tabs button { padding: 0 10px; }
  .panel-list { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; }
  .embed-field-row { grid-template-columns: 1fr; }
}
