:root {
  color-scheme: dark;

  --bg: #0c0f13;
  --bg-soft: #11151a;
  --sidebar: #101419;
  --surface: #151a20;
  --surface-raised: #1a2027;
  --surface-hover: #202832;

  --line: #29313b;
  --line-soft: #202730;

  --text: #eef1f4;
  --muted: #929ca8;
  --subtle: #697481;

  --accent: #557c78;
  --accent-hover: #648e89;
  --accent-soft: rgba(85, 124, 120, 0.17);

  --success: #78aa8d;
  --danger: #ba6f72;
  --warning: #aa9264;

  --radius-small: 8px;
  --radius: 12px;
  --radius-large: 16px;

  --shadow: 0 18px 45px rgba(0, 0, 0, 0.23);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 70% -10%, rgba(85, 124, 120, 0.11), transparent 35%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface-raised);
  color: var(--text);
  padding: 9px 14px;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

button:hover,
.button:hover {
  border-color: #3b4652;
  background: var(--surface-hover);
}

button:active {
  transform: translateY(1px);
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 650;
}

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

button.ghost {
  background: transparent;
}

button.danger {
  border-color: rgba(186, 111, 114, 0.45);
  background: rgba(186, 111, 114, 0.11);
  color: #e2a5a7;
}

.small-button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  z-index: 200;
  top: 0;
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(12, 15, 19, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(85, 124, 120, 0.55);
  border-radius: 11px;
  background: var(--accent-soft);
  color: #9fbab6;
  font-size: 19px;
  font-weight: 800;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--accent-hover);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.18em;
}

h1 {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 680;
}

h2 {
  margin: 2px 0 4px;
  font-size: 25px;
  letter-spacing: -0.025em;
}

h3 {
  margin: 0;
  font-size: 16px;
}

h4 {
  margin: 22px 0 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

p {
  margin: 0;
}

.muted,
.help,
small {
  color: var(--muted);
}

.help {
  margin-top: -4px;
  font-size: 12px;
  font-weight: 400;
}

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

.sidebar {
  position: sticky;
  top: 74px;
  height: calc(100vh - 74px);
  overflow-y: auto;
  border-right: 1px solid var(--line-soft);
  background: rgba(16, 20, 25, 0.85);
  padding: 20px 14px;
}

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

.server-box label {
  color: var(--subtle);
  font-size: 11px;
  text-transform: uppercase;
}

nav {
  display: grid;
  gap: 3px;
}

.nav-label {
  margin: 17px 10px 6px;
  color: #5e6975;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

nav button {
  justify-content: flex-start;
  min-height: 39px;
  border-color: transparent;
  background: transparent;
  color: #abb3bd;
  padding: 8px 11px;
}

nav button span {
  width: 18px;
  color: #73808d;
  text-align: center;
}

nav button:hover {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.035);
}

nav button.active {
  border-color: rgba(85, 124, 120, 0.3);
  background: var(--accent-soft);
  color: #e8eeee;
}

nav button.active span {
  color: #89aaa6;
}

.workspace {
  min-width: 0;
  padding: 28px clamp(20px, 4vw, 52px) 60px;
}

.workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.workspace-header > div:first-child > p:last-child {
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.save-state {
  color: var(--subtle);
  font-size: 12px;
}

.save-state.unsaved {
  color: var(--warning);
}

#notice {
  min-height: 0;
  margin-bottom: 14px;
  border-radius: var(--radius-small);
  font-size: 13px;
}

#notice:not(:empty) {
  padding: 10px 13px;
  border: 1px solid var(--line);
  background: var(--surface);
}

#notice.success {
  border-color: rgba(120, 170, 141, 0.35);
  color: #94c5a8;
}

#notice.error {
  border-color: rgba(186, 111, 114, 0.4);
  color: #dfa0a2;
}

.tab {
  display: none;
}

.tab.active {
  display: block;
  animation: show-tab 160ms ease;
}

@keyframes show-tab {
  from {
    opacity: 0;
    transform: translateY(3px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.card {
  margin-bottom: 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-large);
  background: rgba(21, 26, 32, 0.84);
  padding: 20px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.015);
}

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

.card-heading > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: #8eaaa7;
  font-size: 13px;
}

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

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

.stack {
  display: grid;
  gap: 14px;
}

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

label {
  display: grid;
  min-width: 0;
  gap: 7px;
  color: #b6bec7;
  font-size: 13px;
  font-weight: 560;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  outline: none;
  background: #10151a;
  color: var(--text);
  padding: 9px 11px;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #37424e;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: #12181e;
  box-shadow: 0 0 0 3px rgba(85, 124, 120, 0.12);
}

select {
  cursor: pointer;
}

select option {
  background: #141a20;
  color: var(--text);
}

select[multiple] {
  min-height: 110px;
}

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

input[type="color"] {
  height: 44px;
  padding: 5px;
}

input[type="checkbox"] {
  width: 17px;
  min-height: 17px;
  height: 17px;
  accent-color: var(--accent);
}

fieldset {
  display: grid;
  gap: 13px;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
}

legend {
  padding: 0 8px;
  color: #bdc5ce;
  font-weight: 650;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(21, 26, 32, 0.75);
  padding: 17px;
}

.metric-card span,
.metric-card small {
  display: block;
}

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

.metric-card strong {
  display: block;
  overflow: hidden;
  margin: 6px 0 2px;
  color: var(--text);
  font-size: 21px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 11px;
}

.status-badge.good {
  border-color: rgba(120, 170, 141, 0.35);
  background: rgba(120, 170, 141, 0.1);
  color: #91c2a4;
}

.status-badge.warning {
  border-color: rgba(170, 146, 100, 0.38);
  background: rgba(170, 146, 100, 0.1);
  color: #c8af7d;
}

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

.check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 0;
}

.check-item:last-child {
  border-bottom: 0;
}

.check-state {
  color: var(--success);
  font-size: 12px;
}

.check-state.missing {
  color: var(--warning);
}

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

.quick-link {
  display: grid;
  justify-content: stretch;
  min-height: 80px;
  border-color: var(--line-soft);
  background: #12171d;
  padding: 14px;
  text-align: left;
}

.quick-link strong,
.quick-link span {
  display: block;
}

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

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

.milestone-row {
  display: grid;
  grid-template-columns: 70px 1fr 1fr;
  align-items: end;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 10px;
}

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

.permission-list {
  display: grid;
  gap: 13px;
}

.permission-group {
  display: grid;
  grid-template-columns: 170px 1fr 1fr;
  align-items: start;
  gap: 14px;
  border-bottom: 1px solid var(--line-soft);
  padding: 5px 0 17px;
}

.permission-group:last-child {
  border-bottom: 0;
}

.permission-name {
  padding-top: 9px;
  color: #c6cdd4;
  font-weight: 650;
}

.native-role-select {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.role-dropdown {
  position: relative;
  width: 100%;
}

.role-dropdown > summary {
  list-style: none;
}

.role-dropdown > summary::-webkit-details-marker {
  display: none;
}

.role-dropdown-summary {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: #10151a;
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
}

.role-dropdown[open] .role-dropdown-summary {
  border-color: var(--accent);
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

.role-dropdown-value {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 5px;
}

.role-placeholder {
  color: var(--subtle);
  font-weight: 400;
}

.role-dropdown-arrow {
  flex: 0 0 auto;
  color: var(--muted);
}

.role-chip {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 6px;
  border: 1px solid #33404b;
  border-radius: 999px;
  background: #1b242b;
  color: #d9dee3;
  padding: 3px 7px;
  font-size: 12px;
}

.role-chip i,
.role-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--role-color, #99aab5);
}

.role-dropdown-panel {
  position: absolute;
  z-index: 300;
  top: 100%;
  right: 0;
  left: 0;
  border: 1px solid var(--accent);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: #13191f;
  padding: 9px;
  box-shadow: var(--shadow);
}

.role-dropdown-search {
  margin-bottom: 8px;
}

.role-dropdown-list {
  display: grid;
  max-height: 240px;
  gap: 3px;
  overflow-y: auto;
}

.role-dropdown-option {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 9px;
  border-radius: 7px;
  color: #d2d7dd;
  padding: 8px;
  cursor: pointer;
}

.role-dropdown-option:hover {
  background: var(--surface-hover);
}

.role-dropdown-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 9px;
}

.checkbox-list {
  display: grid;
  gap: 8px;
}

.checkbox-list > label,
.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-small);
  background: #11171c;
  padding: 11px;
  cursor: pointer;
}

.checkbox-list > label:hover {
  border-color: #36414c;
}

.checkbox-list span {
  display: grid;
  gap: 2px;
}

.checkbox-list small,
.switch-row small {
  font-weight: 400;
}

.switch-row {
  justify-content: space-between;
}

.switch-row > span {
  display: grid;
}

.button-row {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
}

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

.user-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #11171c;
  padding: 13px;
}

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

.user-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.user-grants {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.user-tag {
  border-radius: 999px;
  background: var(--accent-soft);
  color: #9db9b6;
  padding: 3px 7px;
  font-size: 11px;
}

.user-status {
  color: var(--success);
  font-size: 11px;
}

.user-status.inactive {
  color: var(--danger);
}

.stats-output {
  min-height: 130px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #10151a;
  color: #b7c0c8;
  padding: 15px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.empty-state {
  color: var(--muted);
  padding: 24px 8px;
  text-align: center;
}

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

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

  .permission-name {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .topbar {
    padding: 12px 16px;
  }

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

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

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

  .nav-label {
    grid-column: 1 / -1;
  }

  .workspace {
    padding: 22px 16px 50px;
  }

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

  .header-actions {
    justify-content: space-between;
  }

  .section-grid,
  .form-grid,
  .language-grid,
  .quick-grid {
    grid-template-columns: 1fr;
  }

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

  .milestone-row strong {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  nav {
    grid-template-columns: 1fr;
  }

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

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

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

  .topbar {
    align-items: flex-start;
  }
}
