:root {
  --bg: #141210;
  --bg-elevated: #1c1916;
  --bg-panel: #221f1b;
  --bg-hover: #2a2621;
  --line: #3a342c;
  --text: #f2ebe1;
  --text-muted: #a89c8c;
  --accent: #d4834a;
  --accent-soft: rgba(212, 131, 74, 0.16);
  --ok: #8fbf7a;
  --danger: #d66a5a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font: "DM Sans", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  min-height: 100vh;
}

a {
  color: inherit;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--accent);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #1a120c;
  padding: 0.6rem 1rem;
  z-index: 100;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
}

h1, h2 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: #53483c;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a120c;
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.05);
  background: var(--accent);
}

.btn.ghost {
  background: transparent;
}

.btn.compact {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

/* Login */
.login-page {
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(212, 131, 74, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 20%, rgba(90, 70, 45, 0.35), transparent 50%),
    linear-gradient(160deg, #181511 0%, #0f0e0c 55%, #17130f 100%);
}

.login-shell {
  width: min(460px, 100%);
  position: relative;
}

.login-panel {
  position: relative;
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 2.4rem 2.2rem 2rem;
  box-shadow: var(--shadow);
  animation: rise 480ms cubic-bezier(0.22, 1, 0.36, 1);
}

.login-panel h1 {
  font-size: clamp(2.4rem, 6vw, 3.2rem);
  margin-top: 0.35rem;
  line-height: 1;
}

.login-lede {
  color: var(--text-muted);
  line-height: 1.55;
  margin: 1rem 0 1.75rem;
}

.login-form {
  display: grid;
  gap: 1rem;
}

.login-form label {
  display: grid;
  gap: 0.4rem;
}

.login-form label span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.login-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: #12100e;
  color: var(--text);
  border-radius: 10px;
  padding: 0.85rem 0.95rem;
  font: inherit;
}

.password-field {
  position: relative;
  display: grid;
}

.password-field input {
  padding-right: 2.85rem;
}

.password-toggle {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--text);
  background: var(--bg-hover);
  outline: none;
}

.password-toggle:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 65%, white);
  outline-offset: 1px;
}

.login-form input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 65%, white);
  outline-offset: 1px;
  border-color: var(--accent);
}

.form-error {
  margin: 0;
  color: #ffb4a8;
  background: rgba(214, 106, 90, 0.12);
  border: 1px solid rgba(214, 106, 90, 0.35);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
}

.login-hint {
  margin: 1.4rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* App shell */
.app-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    linear-gradient(180deg, rgba(212, 131, 74, 0.05), transparent 180px),
    var(--bg);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr auto;
  gap: 1.25rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-block h1 {
  font-size: 1.45rem;
  margin-top: 0.15rem;
}

.url-tray {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.55rem 0.45rem 1rem;
  min-width: 0;
}

.url-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.public-url {
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.public-url:hover {
  color: var(--accent);
}

.url-actions {
  display: flex;
  gap: 0.35rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-user {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 78px);
}

.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1rem 0.5rem;
}

.sidebar-head h2 {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-search {
  padding: 0 0.85rem 0.85rem;
  display: grid;
  gap: 0.5rem;
}

.search-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.search-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--line);
  background: #0e0c0a;
  border-radius: 12px;
  padding: 0 0.85rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.search-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.search-icon {
  color: var(--text-muted);
  flex: 0 0 auto;
}

.search-field:focus-within .search-icon {
  color: var(--accent);
}

.sidebar-search input[type="search"] {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0.8rem 0;
  font: inherit;
  min-width: 0;
}

.sidebar-search input[type="search"]::placeholder {
  color: color-mix(in srgb, var(--text-muted) 85%, transparent);
}

.sidebar-search input[type="search"]:focus {
  outline: none;
}

.sidebar-search input[type="search"]::-webkit-search-cancel-button {
  appearance: none;
  height: 14px;
  width: 14px;
  background: var(--text-muted);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M6.4 5 5 6.4 10.6 12 5 17.6 6.4 19 12 13.4 17.6 19 19 17.6 13.4 12 19 6.4 17.6 5 12 10.6z'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M6.4 5 5 6.4 10.6 12 5 17.6 6.4 19 12 13.4 17.6 19 19 17.6 13.4 12 19 6.4 17.6 5 12 10.6z'/%3E%3C/svg%3E") center / contain no-repeat;
  cursor: pointer;
}

.project-count {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--mono);
  padding: 0 0.15rem;
}

.sidebar-split {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(160px, 38%);
  min-height: 0;
  flex: 1;
  border-top: 1px solid var(--line);
}

.customer-pane,
.release-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.customer-pane {
  border-bottom: 1px solid var(--line);
}

.release-pane-head {
  padding: 0.75rem 1rem 0.35rem;
  display: grid;
  gap: 0.15rem;
}

.release-pane-head h3 {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.release-context {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.84rem;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-list,
.release-list {
  padding: 0.25rem 0.6rem 1rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.project-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  font: inherit;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  transition: background 140ms ease, border-color 140ms ease;
}

.project-btn:hover,
.project-btn:focus-visible {
  background: var(--bg-hover);
  outline: none;
}

.project-btn.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.project-btn-name {
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.project-btn-meta {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.env-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  font: inherit;
  display: grid;
  gap: 0.2rem;
  transition: background 140ms ease, border-color 140ms ease;
}

.env-btn:hover,
.env-btn:focus-visible {
  background: var(--bg-hover);
  outline: none;
}

.env-btn.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.env-btn .env-title {
  font-weight: 600;
  text-transform: capitalize;
}

.env-btn .env-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.empty-state.subtle {
  padding-top: 1rem;
}

.file-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.path-bar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-panel) 70%, transparent);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.84rem;
}

.breadcrumb button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 0.15rem 0.25rem;
  border-radius: 6px;
}

.breadcrumb button:hover {
  background: var(--accent-soft);
}

.breadcrumb .sep {
  color: var(--text-muted);
}

.selection-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.file-table th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
}

.file-table td {
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  vertical-align: middle;
}

.file-table tbody tr {
  transition: background 120ms ease;
}

.file-table tbody tr:hover {
  background: var(--bg-hover);
}

.file-table tbody tr:focus-within {
  background: var(--accent-soft);
}

.name-cell {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.icon {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.icon.dir {
  background: rgba(212, 131, 74, 0.18);
  color: var(--accent);
}

.icon.file {
  background: rgba(168, 156, 140, 0.16);
  color: var(--text-muted);
}

.name-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.name-btn:hover {
  color: var(--accent);
}

.mono {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.row-url {
  color: var(--text-muted);
  text-decoration: none;
  max-width: 28rem;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-url:hover {
  color: var(--accent);
}

.placeholder-row td,
.empty-state {
  color: var(--text-muted);
  padding: 2rem 1.25rem;
}

.toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  background: #2c2620;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.8rem 1rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: rise 220ms ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 960px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

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

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
  }

  .sidebar-split {
    grid-template-rows: minmax(160px, 220px) minmax(120px, 180px);
  }

  .url-tray {
    grid-template-columns: 1fr;
    border-radius: 14px;
    padding: 0.75rem;
  }

  .url-actions {
    justify-content: flex-start;
  }

  .path-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}
