:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1d212b;
  --panel-3: #202532;
  --text: #eef2ff;
  --muted: #9aa4bf;
  --border: #2a3242;
  --primary: #5b8cff;
  --primary-2: #7ca4ff;
  --success: #2fbf71;
  --warning: #f2b84b;
  --danger: #ff5f73;
  --shadow: 0 14px 40px rgba(0,0,0,.28);
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a { color: inherit; text-decoration: none; }
code { word-break: break-all; }

.mobile-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(15,17,21,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.mobile-topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-menu-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
}

.app-shell {
  display: block;
  min-height: calc(100vh - 67px);
}

.rail { display: none; }

.sidebar-stack {
  position: fixed;
  inset: 67px auto 0 0;
  z-index: 60;
  width: min(92vw, 380px);
  height: calc(100vh - 67px);
  padding: 16px;
  overflow: auto;
  background: #11151d;
  border-right: 1px solid var(--border);
  transform: translateX(-104%);
  transition: transform .22s ease;
}
html.sidebar-open .sidebar-stack { transform: translateX(0); }
.mobile-backdrop {
  position: fixed;
  inset: 67px 0 0 0;
  background: rgba(0,0,0,.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
  z-index: 55;
}
html.sidebar-open .mobile-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.projects-panel,
.access-panel,
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.projects-panel,
.access-panel { padding: 16px; }
.access-panel { margin-top: 16px; }
.card { padding: 18px; }
.content { padding: 16px; }
.content-head { margin-bottom: 18px; }
.content-head h1 { margin: 0 0 8px; font-size: clamp(26px, 4vw, 36px); }
.content-head p { margin: 0; color: var(--muted); max-width: 880px; }
.desktop-userbar { display: none; }
.top-userbar { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 14px; }
.user-pill {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 999px;
  background: #24304a;
  color: #cfe0ff;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.projects-head { display: grid; gap: 14px; margin-bottom: 16px; }
.current-project { font-size: 18px; font-weight: 700; }
.projects-list { display: grid; gap: 10px; max-height: 42vh; overflow: auto; padding-right: 4px; }
.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid transparent;
}
.project-item.active { border-color: var(--primary); background: #182236; }
.project-item a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-add-box { margin-top: 16px; }

.stack-form { display: grid; gap: 10px; }
.compact { gap: 12px; }
.grid-two { display: grid; gap: 16px; margin-bottom: 16px; }
.users-grid { margin-bottom: 0; }
.search-form input,
.stack-form input,
.stack-form select {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
}
.search-form input::placeholder,
.stack-form input::placeholder { color: #7f89a0; }
label { font-size: 14px; color: var(--muted); }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.checkbox-row input { width: 18px; height: 18px; min-height: 18px; }
.checkbox-row.small { font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-sm { min-height: 38px; padding: 8px 12px; }
.btn-full { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: #2b3550; color: #fff; }
.btn-light { background: var(--panel-2); border-color: var(--border); color: var(--text); }
.btn-danger { background: rgba(255,95,115,.12); border-color: rgba(255,95,115,.2); color: #ff95a2; }
.btn-link { color: #a7c1ff; font-weight: 700; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); cursor: pointer;
}
.icon-btn.danger { color: #ff8b98; }

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.notice.success { background: rgba(47,191,113,.12); border-color: rgba(47,191,113,.24); }
.notice.error { background: rgba(255,95,115,.12); border-color: rgba(255,95,115,.24); }

.tabs-row { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
}
.tab.active { background: #1b2840; color: #d8e5ff; border: 1px solid rgba(91,140,255,.45); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.card-table { border: 0; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}
th { color: var(--muted); font-weight: 600; background: rgba(255,255,255,.02); }
tr:last-child td { border-bottom: 0; }
.empty-cell { text-align: center; color: var(--muted); }

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.inline-edit {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.inline-edit input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.green { background: rgba(47,191,113,.14); color: #87efaf; }
.badge.red { background: rgba(255,95,115,.14); color: #ffacb7; }
.badge.gray { background: rgba(255,255,255,.08); color: #c5cbda; }
.badge.warn { background: rgba(242,184,75,.14); color: #ffd582; }

.chips-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13px;
}
.subblock + .subblock { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.subblock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.break-all, .error-text { word-break: break-word; }
.error-text { margin-top: 10px; color: #ff97a4; font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.small-space { margin-top: 14px; }
.empty-page { min-height: 220px; display: grid; align-content: center; }
.empty-state.small { color: var(--muted); padding: 12px 0; }

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 8px; }
.login-card p { margin: 0 0 16px; color: var(--muted); }

@media (max-width: 767px) {
  .responsive-table thead { display: none; }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table tr {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,.01);
  }
  .responsive-table td {
    padding: 8px 0;
    border: 0;
  }
  .responsive-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }
}

@media (min-width: 768px) {
  .content { padding: 24px; }
  .grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-edit { grid-template-columns: 140px auto auto; align-items: center; }
}

@media (min-width: 1024px) {
  .mobile-topbar { display: none; }
  .app-shell {
    display: grid;
    grid-template-columns: 72px 360px minmax(0, 1fr);
    min-height: 100vh;
  }
  .rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 20px 12px;
    border-right: 1px solid var(--border);
    background: #10141b;
  }
  .brand, .rail-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
  }
  .rail-icon.active { background: #1c2941; border-color: rgba(91,140,255,.45); }
  .sidebar-stack {
    position: sticky;
    inset: 0 auto 0 0;
    width: auto;
    height: 100vh;
    transform: none;
    padding: 20px;
    background: #121722;
    overflow: auto;
  }
  .mobile-backdrop { display: none; }
  .desktop-userbar { display: flex; }
  .content { padding: 24px 28px; }
  .projects-list { max-height: 48vh; }
}


.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.sidebar-tab {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
}
.sidebar-tab.active { background: #1a2740; color: #dce8ff; border-color: rgba(91,140,255,.45); }
.sidebar-panel { display: none; }
.sidebar-panel.active { display: block; }
.grid-one { display: grid; gap: 16px; }
.inner-card { padding: 18px; }
.users-table-wrap { max-height: 360px; overflow: auto; }
.rail-icon.muted { opacity: .45; }

@media (min-width: 1024px) {
  .sidebar-tabs { margin-bottom: 16px; }
}

.projects-checklist {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.02);
}
.projects-checklist.compact-list { max-height: 160px; margin: 10px 0; }
.check-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
}
.check-tile input { width: 18px; height: 18px; min-height: 18px; }
.user-projects-form { margin-top: 10px; }

.main-panel { display: none; }
.main-panel.active { display: block; }
.workspace-head { margin-bottom: 18px; }
.workspace-head h1 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 40px); }
.workspace-head p { margin: 0; color: var(--muted); max-width: 760px; }
.access-workspace { min-height: 100%; }
.access-full-card { padding: 0; background: transparent; border: 0; box-shadow: none; }
.access-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}
.access-form-card,
.access-users-card { min-height: 100%; }
.wide-table-wrap { max-height: none; }

@media (min-width: 1200px) {
  .access-layout {
    grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
    align-items: start;
  }
  .access-users-card { min-height: calc(100vh - 180px); }
}

.sidebar-panel{display:block}.main-panel{display:none}.main-panel.active{display:block}.workspace-head{margin-bottom:18px}.workspace-head h1{margin:0 0 8px;font-size:clamp(28px,4vw,40px)}.workspace-head p{margin:0;color:var(--muted);max-width:760px}.access-layout{display:grid;gap:18px;grid-template-columns:1fr}.access-form-card,.access-users-card{min-height:100%}.wide-table-wrap{max-height:none}@media (min-width:1200px){.access-layout{grid-template-columns:minmax(340px,420px) minmax(0,1fr);align-items:start}.access-users-card{min-height:calc(100vh - 180px)}}