:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: #202735;
  background: #eef1f5;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.portal-shell {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.portal-header,
.account {
  display: flex;
  align-items: center;
}

.portal-header {
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}

.portal-header h1,
.login-form h1 {
  margin: 0;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 6px;
  color: #526173;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.account {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  color: #24523b;
  background: #d9f1e3;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-card,
.invite-card {
  padding: 28px;
  border: 1px solid #d7dde5;
  background: #ffffff;
  box-shadow: 0 12px 30px rgb(32 39 53 / 8%);
}

.status-card h2 {
  margin-top: 0;
}

.status-card p {
  max-width: 65ch;
  margin-bottom: 0;
  color: #526173;
  line-height: 1.6;
}

.admin-section,
.projects-section {
  margin-top: 24px;
}

.section-heading,
.inline-form-controls,
.record-row {
  display: flex;
  align-items: center;
}

.section-heading {
  justify-content: space-between;
  gap: 24px;
}

.inline-form {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.inline-form label,
.invite-result label {
  font-size: 0.9rem;
  font-weight: 700;
}

.inline-form-controls {
  gap: 10px;
}

.inline-form-controls input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #aeb8c5;
  border-radius: 4px;
}

.inline-form-controls .primary-button {
  margin-top: 0;
}

.invite-result {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  padding: 16px;
  border: 1px solid #b8d3c2;
  background: #f0faf4;
}

.invite-result p {
  margin: 0;
  font-size: 0.85rem;
}

.form-message {
  margin: 16px 0 0;
  color: #24523b;
  font-size: 0.9rem;
  font-weight: 700;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 28px;
}

.admin-grid h3 {
  margin-top: 0;
}

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

.record-row {
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid #d7dde5;
  background: #f8f9fb;
}

.record-row > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.record-row .record-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.record-row small,
.empty-record {
  color: #687587;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.projects-grid > .empty-record {
  grid-column: 1 / -1;
}

.project-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid #d7dde5;
  background: #f8f9fb;
}

.project-card-heading,
.project-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.project-card h3,
.project-created {
  margin: 0;
}

.project-created {
  color: #687587;
  font-size: 0.85rem;
}

.status-badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-new {
  color: #4c566a;
  background: #e5e9f0;
}

.status-in_progress {
  color: #72530a;
  background: #fff0bd;
}

.status-production {
  color: #24523b;
  background: #d9f1e3;
}

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

.project-controls label {
  display: grid;
  gap: 6px;
  color: #526173;
  font-size: 0.8rem;
  font-weight: 700;
}

.project-controls select {
  width: 100%;
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid #aeb8c5;
  border-radius: 4px;
  background: #ffffff;
}

.explorer-dialog {
  width: min(1000px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid #d7dde5;
  background: #ffffff;
  box-shadow: 0 24px 70px rgb(20 27 38 / 24%);
}

.explorer-dialog::backdrop {
  background: rgb(27 35 48 / 58%);
  backdrop-filter: blur(3px);
}

.explorer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px;
  border-bottom: 1px solid #d7dde5;
}

.explorer-header h2 {
  margin: 0;
}

.explorer-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(0, 2fr);
  min-height: 460px;
}

.explorer-layout nav {
  overflow: auto;
  padding: 20px;
  border-right: 1px solid #d7dde5;
  background: #f8f9fb;
}

.file-tree ul {
  margin: 0;
  padding-left: 18px;
  list-style: none;
}

.file-tree > ul {
  padding-left: 0;
}

.file-tree li {
  margin: 5px 0;
}

.tree-directory,
.tree-file {
  display: block;
  width: 100%;
  padding: 5px 7px;
  border: 0;
  color: #202735;
  background: transparent;
  text-align: left;
}

.tree-directory {
  font-weight: 700;
}

.tree-directory::before {
  content: "▾ ";
  color: #687587;
}

.tree-file:hover {
  background: #e5e9f0;
}

.file-preview {
  min-width: 0;
  padding: 20px;
}

.file-path {
  margin-top: 0;
  color: #526173;
  font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", monospace;
  font-size: 0.85rem;
}

.file-preview pre {
  overflow: auto;
  min-height: 380px;
  max-height: 60vh;
  margin: 0;
  padding: 16px;
  border: 1px solid #d7dde5;
  color: #e5e9f0;
  background: #2e3440;
  font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", monospace;
  font-size: 0.86rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.explorer-dialog > .form-error {
  margin: 0;
  padding: 12px 24px;
  border-top: 1px solid #d7dde5;
}

.record-row select {
  max-width: 148px;
  min-height: 38px;
  padding: 6px 8px;
  border: 1px solid #aeb8c5;
  border-radius: 4px;
  background: #ffffff;
}

.empty-record {
  margin: 0;
  padding: 16px;
  border: 1px dashed #c4ccd6;
}

.login-dialog {
  width: min(440px, calc(100% - 32px));
  padding: 0;
  border: 1px solid #d7dde5;
  background: #ffffff;
  box-shadow: 0 24px 70px rgb(20 27 38 / 24%);
}

.login-dialog::backdrop {
  background: rgb(27 35 48 / 58%);
  backdrop-filter: blur(3px);
}

.login-form {
  display: grid;
  gap: 12px;
  padding: 32px;
}

.form-description {
  margin: 0 0 8px;
  color: #526173;
}

.login-form label {
  margin-top: 4px;
  font-size: 0.9rem;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #aeb8c5;
  border-radius: 4px;
  color: #202735;
  background: #ffffff;
}

.login-form input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 3px solid rgb(52 102 164 / 30%);
  outline-offset: 2px;
}

.form-error {
  margin: 4px 0 0;
  color: #a52b2b;
  font-size: 0.9rem;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 4px;
  font-weight: 700;
}

.danger-button {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid #c98a8a;
  border-radius: 4px;
  color: #8b2424;
  background: #fff7f7;
  font-weight: 700;
}

.invite-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.invite-card {
  width: min(480px, 100%);
}

.invite-card h1 {
  margin-top: 0;
}

.invite-form {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.invite-form input {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #aeb8c5;
  border-radius: 4px;
}

.success-panel {
  padding: 16px;
  border: 1px solid #b8d3c2;
  background: #f0faf4;
}

.primary-button {
  margin-top: 8px;
  border: 1px solid #2d5f9a;
  color: #ffffff;
  background: #3466a4;
}

.button-link {
  display: inline-block;
  text-decoration: none;
}

.secondary-button {
  border: 1px solid #aeb8c5;
  color: #202735;
  background: #ffffff;
}

@media (max-width: 640px) {
  .portal-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .account {
    justify-content: flex-start;
  }

  .login-form {
    padding: 24px;
  }

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

  .projects-grid,
  .project-controls,
  .explorer-layout {
    grid-template-columns: 1fr;
  }

  .explorer-layout nav {
    max-height: 240px;
    border-right: 0;
    border-bottom: 1px solid #d7dde5;
  }

  .inline-form-controls {
    align-items: stretch;
    flex-direction: column;
  }
}
