:root {
  --bg: #090d16;
  --bg-soft: #111a2d;
  --panel: #121d33;
  --panel-border: #24365f;
  --text: #e7ecff;
  --muted: #95a6d3;
  --primary: #5a8cff;
  --primary-hover: #79a0ff;
  --danger: #d84d65;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(circle at top right, #172544 0%, var(--bg) 42%);
  color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar-shell {
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.2rem;
  border-right: 1px solid var(--panel-border);
  background: rgba(10, 16, 30, 0.78);
  backdrop-filter: blur(10px);
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.2rem;
}

.nav-links a {
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid transparent;
}

.nav-links a:hover,
.nav-links a.active {
  background: #1a2b50;
  border-color: #335393;
}

.content {
  padding: 2rem;
  max-width: 1250px;
  width: 100%;
}

.page-header {
  margin-bottom: 1rem;
}

.card {
  background: linear-gradient(180deg, rgba(20, 32, 58, 0.92) 0%, rgba(15, 24, 44, 0.92) 100%);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 25px rgba(3, 8, 20, 0.28);
}

.row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}

.between {
  justify-content: space-between;
}

.form-grid {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}

.form-grid.three {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

input, button, select {
  padding: 0.58rem 0.7rem;
  border-radius: 9px;
  border: 1px solid #314a82;
  background: #0d1730;
  color: var(--text);
}

input:focus, select:focus {
  outline: 2px solid #3a62b4;
}

button {
  cursor: pointer;
  transition: 0.16s ease;
}

.btn-primary {
  background: var(--primary);
  border-color: #5f93ff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #1d2d52;
}

.btn-secondary:hover {
  background: #274073;
}

.btn-danger {
  background: var(--danger);
  border-color: #d84d65;
}

.btn-link {
  color: #bcd0ff;
  text-decoration: none;
  padding: 0.5rem 0.7rem;
  border: 1px solid #2c4679;
  border-radius: 9px;
}

.btn-link:hover {
  background: #1d2f56;
}

.muted {
  color: var(--muted);
  margin: 0.2rem 0;
}

.status-message {
  color: #aecdff;
  min-height: 1.2rem;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-item {
  border: 1px solid #293f6d;
  border-radius: 11px;
  padding: 0.75rem;
  margin-bottom: 0.65rem;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}

.permission-tile {
  text-align: left;
  background: #1c2946;
  border: 1px solid #314a82;
}

.permission-tile.active {
  background: #1f5f3c !important;
  border-color: #2f9c62 !important;
  color: #e8ffee !important;
  box-shadow: inset 0 0 0 1px rgba(127, 255, 176, 0.22);
}

.permission-tile:hover {
  filter: brightness(1.07);
}

.files-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0.8rem;
}

.files-list-panel,
.files-editor-panel {
  border: 1px solid #293f6d;
  border-radius: 10px;
  background: rgba(9, 20, 42, 0.75);
  padding: 0.7rem;
  min-height: 460px;
}

.files-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 620px;
  overflow: auto;
}

.files-tree {
  list-style: none;
  margin: 0;
  padding-left: 1rem;
}

.tree-folder > details {
  margin: 0.2rem 0;
}

.tree-folder summary {
  cursor: pointer;
  color: #d6e2ff;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.84rem;
}

.tree-file-btn {
  width: 100%;
  margin: 0.2rem 0;
  border: 1px solid #2a4479;
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  background: #102047;
  color: #e7ecff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.45rem;
  text-align: left;
}

.tree-file-btn.active {
  background: #1d2f56;
  border-color: #4c70bc;
}

.lock-badge {
  border: 1px solid #6f8ccc;
  border-radius: 999px;
  padding: 0.08rem 0.45rem;
  font-size: 0.72rem;
  color: #cfe0ff;
}

.lock-badge.locked {
  border-color: #2f9c62;
  color: #cbffe0;
  background: rgba(31, 95, 60, 0.45);
}

#file-editor {
  width: 100%;
  min-height: 420px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
}

pre {
  background: #081027;
  border: 1px solid #2a4479;
  border-radius: 10px;
  padding: 0.9rem;
  min-height: 300px;
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
}

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.login-shell {
  width: min(560px, 92vw);
}

.login-card h1 {
  margin-top: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(1, 7, 18, 0.72);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 9999;
}

.modal-card {
  width: min(520px, 92vw);
  background: linear-gradient(180deg, rgba(20, 32, 58, 0.98) 0%, rgba(15, 24, 44, 0.98) 100%);
  border: 1px solid #335393;
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: 0 15px 35px rgba(3, 8, 20, 0.45);
}

.hidden {
  display: none !important;
}

.modal-backdrop.hidden {
  display: none !important;
}
