:root {
  --primary: #2563eb;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #dbe4ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
}

html.prompthub-web-runtime {
  --base-font-size: 17px;
}

body.prompthub-web-runtime {
  min-height: 100vh;
}

#root {
  min-height: 100vh;
}

@media (min-width: 1440px) {
  html.prompthub-web-runtime {
    --base-font-size: 18px;
  }
}

@media (max-width: 1280px) {
  html.prompthub-web-runtime {
    --base-font-size: 16px;
  }
}

a {
  color: inherit;
  text-decoration: none;
}

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

.layout-container {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.layout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.layout-branding {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.layout-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.layout-subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.layout-nav {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.layout-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.625rem 0.875rem;
  border-radius: 0.75rem;
}

.layout-body {
  display: flex;
  flex: 1;
}

.layout-sidebar {
  width: 250px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 1rem;
}

.layout-sidenav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.layout-sidenav-link {
  display: flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.625rem 0.875rem;
  border-radius: 0.75rem;
  color: var(--text-muted);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.layout-sidenav-link:hover {
  background: #eef2ff;
  color: var(--text-main);
}

.layout-sidenav-link-active {
  background: var(--primary);
  color: #ffffff;
}

.layout-main {
  flex: 1;
  padding: 1.5rem;
}

.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-size: 1.25rem;
  color: var(--text-muted);
}

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-main);
  padding: 1.5rem;
}

.login-card {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  width: 100%;
  max-width: 420px;
}

.setup-card {
  max-width: 520px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.08);
}

.setup-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  margin-bottom: 1rem;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.8rem;
  font-weight: 700;
}

.setup-lead {
  margin: 0 0 0.75rem;
  color: var(--text-main);
  text-align: center;
}

.setup-hint {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.95rem;
}

.login-title {
  text-align: center;
  margin: 0 0 1.5rem;
}

.login-error {
  color: #b91c1c;
  margin-bottom: 1rem;
  text-align: center;
  border-radius: 0.875rem;
  background: #fef2f2;
  padding: 0.75rem 0.875rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
}

.form-group input,
.form-group textarea {
  padding: 0.75rem 0.875rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
}

.prompthub-web-auth .web-auth-input {
  width: 100%;
  min-height: 3.25rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.9rem;
  background: #f8fafc;
  color: #0f172a;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.04);
}

.prompthub-web-auth .web-auth-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
  background: #ffffff;
}

.prompthub-web-auth .web-auth-submit {
  margin-top: 0.5rem;
  min-height: 3.25rem;
  border-radius: 0.95rem;
  font-size: 1rem;
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.24);
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
  color: #ffffff !important;
  border: 1px solid #1d4ed8 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: 700 !important;
  letter-spacing: 0.01em;
  appearance: none !important;
  -webkit-appearance: none !important;
}

.prompthub-web-auth button.web-auth-submit:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%) !important;
}

.prompthub-web-auth button.web-auth-submit:active {
  transform: translateY(1px);
}

.prompthub-web-auth button.web-auth-submit:focus-visible {
  outline: none !important;
  box-shadow:
    0 0 0 4px rgba(37, 99, 235, 0.16),
    0 14px 30px rgba(37, 99, 235, 0.24) !important;
}

.login-submit,
.primary-button {
  display: inline-flex;
  width: 100%;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

button.login-submit,
button.primary-button {
  appearance: none;
  -webkit-appearance: none;
}

.login-submit:disabled,
.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.secondary-button {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
}

.web-auth-captcha-row {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
}

.web-auth-captcha-prompt {
  flex: 1;
  min-height: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.875rem;
  border-radius: 0.9rem;
  border: 1px dashed #93c5fd;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  color: #1e3a8a;
  font-weight: 700;
  letter-spacing: 0.04em;
  overflow: hidden;
}

.web-auth-captcha-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: contain;
}

.web-auth-captcha-refresh {
  min-width: 7.5rem;
}

@media (max-width: 640px) {
  .web-auth-captcha-row {
    flex-direction: column;
  }

  .web-auth-captcha-refresh {
    width: 100%;
  }
}

.login-toggle {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  width: 100%;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.page-shell {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.page-header-block {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.page-description {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}

.toolbar-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.toolbar-label,
.field-label {
  font-size: 0.875rem;
  font-weight: 600;
}

.toolbar-select,
.field-input,
.field-textarea {
  width: 100%;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg-card);
  color: var(--text-main);
}

.field-textarea {
  min-height: 9rem;
  resize: vertical;
}

.field-textarea-large {
  min-height: 18rem;
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
  gap: 1.5rem;
}

.page-grid-toolbar {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
}

.page-grid-dashboard {
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.2fr);
}

.page-grid-span-full {
  grid-column: 1 / -1;
}

.content-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--bg-card);
}

.section-header {
  display: flex;
  align-items: center;
}

.section-header-spread {
  justify-content: space-between;
  gap: 1rem;
}

.section-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.resource-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.resource-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 0.875rem;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.resource-card-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.resource-card-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
}

.resource-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.resource-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.resource-meta {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.resource-body {
  margin: 0;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.resource-body-truncate {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.resource-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: var(--text-main);
  font-size: 0.875rem;
  font-weight: 600;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  gap: 1.5rem;
}

.detail-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-label {
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.version-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.version-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: #f8fafc;
}

.version-compare-button {
  border: none;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.875rem;
}

.diff-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.diff-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}

.status-banner {
  padding: 0.875rem 1rem;
  border-radius: 0.875rem;
  border: 1px solid var(--border);
}

.status-banner-success {
  background: #ecfdf5;
  color: #166534;
}

.status-banner-error {
  background: #fee2e2;
  color: #b91c1c;
}

.empty-state {
  margin: 0;
  color: var(--text-muted);
}

.data-preview {
  margin: 0;
  padding: 1rem;
  border-radius: 0.75rem;
  background: #0f172a;
  color: #e2e8f0;
  overflow: auto;
  min-height: 10rem;
}

.inline-actions {
  display: flex;
  gap: 0.75rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.checkbox-row-toolbar {
  align-self: end;
  min-height: 2.75rem;
}

@media (max-width: 960px) {
  .layout-body {
    flex-direction: column;
  }

  .layout-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

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

  .page-grid-toolbar,
  .page-grid-dashboard,
  .detail-grid,
  .diff-grid {
    grid-template-columns: 1fr;
  }

  .page-header-block {
    flex-direction: column;
  }
}
