/* ── Prototype Tracker — design tokens ── */
:root {
  --pt-font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pt-bg: #f4f6f9;
  --pt-surface: #ffffff;
  --pt-border: #e2e8f0;
  --pt-border-strong: #cbd5e1;
  --pt-text: #0f172a;
  --pt-text-muted: #64748b;
  --pt-text-subtle: #94a3b8;
  --pt-primary: #2563eb;
  --pt-primary-hover: #1d4ed8;
  --pt-primary-soft: #eff6ff;
  --pt-accent: #0d9488;
  --pt-accent-soft: #f0fdfa;
  --pt-nav-bg: #0f172a;
  --pt-nav-text: #cbd5e1;
  --pt-nav-active: #ffffff;
  --pt-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --pt-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --pt-shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --pt-radius: 0.625rem;
  --pt-radius-lg: 0.875rem;
  --pt-focus: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

/* ── Base ── */
html {
  font-size: 15px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  font-family: var(--pt-font);
  background: var(--pt-bg);
  color: var(--pt-text);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--pt-primary);
  text-decoration: none;
}

a:hover {
  color: var(--pt-primary-hover);
}

/* ── App shell ── */
.app-navbar {
  background: var(--pt-nav-bg);
  padding: 0;
  box-shadow: var(--pt-shadow);
}

.app-navbar .container {
  max-width: 1140px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: #fff !important;
  padding-top: 0.875rem;
  padding-bottom: 0.875rem;
}

.app-brand:hover {
  color: #f8fafc !important;
}

.app-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: linear-gradient(135deg, var(--pt-primary) 0%, var(--pt-accent) 100%);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.app-navbar .nav-link {
  color: var(--pt-nav-text) !important;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 0.875rem !important;
  border-radius: 0.375rem;
  margin: 0 0.125rem;
  transition: color 0.15s, background 0.15s;
}

.app-navbar .nav-link:hover {
  color: var(--pt-nav-active) !important;
  background: rgba(255, 255, 255, 0.08);
}

.app-navbar .nav-link.active {
  color: var(--pt-nav-active) !important;
  background: rgba(255, 255, 255, 0.12);
}

.app-navbar .navbar-toggler {
  border-color: rgba(255, 255, 255, 0.25);
}

.app-navbar .navbar-toggler-icon {
  filter: invert(1);
}

.app-main {
  flex: 1;
  padding: 2rem 0 3rem;
}

.app-main .container {
  max-width: 1140px;
}

.app-footer {
  background: var(--pt-surface);
  border-top: 1px solid var(--pt-border);
  padding: 1.25rem 0;
  color: var(--pt-text-muted);
  font-size: 0.85rem;
}

/* ── Page structure ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.page-header-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 0.375rem;
  color: var(--pt-text);
}

.page-header-subtitle {
  color: var(--pt-text-muted);
  margin: 0;
  font-size: 0.95rem;
  max-width: 36rem;
  line-height: 1.5;
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--pt-text);
  margin-bottom: 1rem;
}

.section-subtitle {
  color: var(--pt-text-muted);
  font-size: 0.875rem;
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

/* ── Breadcrumbs ── */
.breadcrumb {
  background: transparent;
  padding: 0;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
}

.breadcrumb-item a {
  color: var(--pt-text-muted);
  font-weight: 500;
}

.breadcrumb-item a:hover {
  color: var(--pt-primary);
}

.breadcrumb-item.active {
  color: var(--pt-text);
  font-weight: 500;
}

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--pt-text-subtle);
}

/* ── Cards & panels ── */
.card,
.panel-card {
  background: var(--pt-surface);
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius-lg);
  box-shadow: var(--pt-shadow-sm);
}

.card {
  overflow: hidden;
}

.panel-card {
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.panel-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--pt-text-muted);
  margin-bottom: 0.5rem;
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--pt-surface);
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--pt-shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--pt-primary), var(--pt-accent));
  border-radius: 4px 0 0 4px;
}

.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--pt-text);
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.stat-card-label {
  color: var(--pt-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0;
}

/* Timeline / prototype cards */
.timeline-card {
  background: var(--pt-surface);
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius-lg);
  margin-bottom: 1rem;
  box-shadow: var(--pt-shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.timeline-card:hover {
  box-shadow: var(--pt-shadow);
  border-color: var(--pt-border-strong);
}

.timeline-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--pt-border);
  border-radius: var(--pt-radius-lg) var(--pt-radius-lg) 0 0;
}

.timeline-card-header strong {
  font-weight: 600;
  color: var(--pt-text);
}

.timeline-card-header .version-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.2rem 0.5rem;
  background: var(--pt-primary-soft);
  color: var(--pt-primary);
  border-radius: 0.375rem;
  font-size: 0.8rem;
  font-weight: 700;
  margin-right: 0.5rem;
}

.timeline-card-body {
  padding: 1.25rem;
}

/* List groups */
.list-group-item {
  border-color: var(--pt-border);
  padding: 1rem 1.25rem;
}

.list-group-item-action {
  transition: background 0.12s, border-color 0.12s;
}

.list-group-item-action:hover {
  background: #f8fafc;
  border-color: var(--pt-border-strong);
}

.list-group-item-action .list-item-title {
  font-weight: 600;
  color: var(--pt-text);
}

/* ── Tables ── */
.table-app {
  background: var(--pt-surface);
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius-lg);
  overflow: hidden;
  box-shadow: var(--pt-shadow-sm);
  margin-bottom: 0;
}

.table-app thead {
  background: #f8fafc;
}

.table-app thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pt-text-muted);
  border-bottom: 1px solid var(--pt-border);
  padding: 0.875rem 1.25rem;
  white-space: nowrap;
}

.table-app tbody td {
  padding: 1rem 1.25rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--pt-border);
  color: var(--pt-text);
}

.table-app tbody tr:last-child td {
  border-bottom: none;
}

.table-app tbody tr:hover {
  background: #f8fafc;
}

.table-app tbody td a:not(.btn) {
  font-weight: 500;
}

/* ── Badges ── */
.badge {
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  padding: 0.35em 0.65em;
  border-radius: 0.375rem;
}

.badge-status-active,
.badge.bg-secondary {
  background: #e2e8f0 !important;
  color: #475569 !important;
}

.badge-status-prototype,
.badge.bg-info {
  background: var(--pt-primary-soft) !important;
  color: var(--pt-primary) !important;
}

.badge-status-approved,
.badge.bg-success {
  background: #dcfce7 !important;
  color: #15803d !important;
}

.badge-status-rejected,
.badge.bg-danger {
  background: #fee2e2 !important;
  color: #b91c1c !important;
}

.badge-status-pending,
.badge.bg-warning {
  background: #fef3c7 !important;
  color: #b45309 !important;
}

/* ── Buttons ── */
.btn {
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--pt-primary);
  border-color: var(--pt-primary);
  box-shadow: var(--pt-shadow-sm);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--pt-primary-hover);
  border-color: var(--pt-primary-hover);
  box-shadow: var(--pt-shadow);
}

.btn-outline-primary {
  color: var(--pt-primary);
  border-color: var(--pt-border-strong);
}

.btn-outline-primary:hover {
  background: var(--pt-primary-soft);
  border-color: var(--pt-primary);
  color: var(--pt-primary-hover);
}

.btn-outline-secondary {
  color: var(--pt-text-muted);
  border-color: var(--pt-border-strong);
}

.btn-outline-secondary:hover {
  background: #f8fafc;
  color: var(--pt-text);
  border-color: var(--pt-border-strong);
}

.btn-outline-success {
  border-color: #86efac;
  color: #15803d;
}

.btn-outline-success:hover {
  background: #dcfce7;
  border-color: #4ade80;
  color: #15803d;
}

.btn-sm {
  font-size: 0.8125rem;
  padding: 0.3rem 0.75rem;
}

.btn:focus,
.btn:active:focus,
.form-control:focus,
.form-select:focus {
  box-shadow: var(--pt-focus);
  border-color: var(--pt-primary);
}

/* ── Forms ── */
.form-label {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--pt-text);
  margin-bottom: 0.375rem;
}

.form-control,
.form-select {
  border-color: var(--pt-border-strong);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  padding: 0.55rem 0.875rem;
}

.form-control::placeholder {
  color: var(--pt-text-subtle);
}

.form-card {
  background: var(--pt-surface);
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius-lg);
  padding: 1.75rem;
  box-shadow: var(--pt-shadow-sm);
  max-width: 640px;
}

/* ── Comments ── */
.comment-block {
  border-left: 3px solid var(--pt-border-strong);
  padding: 0.5rem 0 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.comment-block p {
  margin-bottom: 0.25rem;
  color: var(--pt-text);
}

/* ── Empty states ── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  background: var(--pt-surface);
  border: 1px dashed var(--pt-border-strong);
  border-radius: var(--pt-radius-lg);
  color: var(--pt-text-muted);
}

.empty-state a {
  font-weight: 500;
}

/* ── Definition lists ── */
dl.row dt {
  color: var(--pt-text-muted);
  font-weight: 500;
  font-size: 0.875rem;
}

dl.row dd {
  color: var(--pt-text);
}

/* ── File previews ── */
.screenshot-preview {
  max-width: 100%;
  max-height: 240px;
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius);
  box-shadow: var(--pt-shadow-sm);
}

.screenshot-preview-trigger {
  display: inline-block;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  border-radius: var(--pt-radius);
}

.screenshot-preview-trigger:hover .screenshot-preview {
  box-shadow: var(--pt-shadow);
}

.screenshot-preview-trigger:focus-visible {
  outline: none;
  box-shadow: var(--pt-focus);
  border-radius: var(--pt-radius);
}

.image-preview-modal .modal-body {
  background: var(--pt-bg);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview-modal-img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: var(--pt-radius);
}

.file-preview-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 0.375rem;
  border: 1px solid var(--pt-border);
  cursor: zoom-in;
}

.prototype-file-path-text {
  word-break: break-all;
  font-size: 0.875em;
}

.btn-copy-path {
  padding: 0.2rem 0.4rem;
  line-height: 1;
  color: var(--pt-text-muted);
  border-color: var(--pt-border-strong);
}

.btn-copy-path:hover {
  color: var(--pt-primary);
  border-color: var(--pt-primary);
  background: var(--pt-primary-soft);
}

.btn-copy-path--copied {
  color: var(--pt-accent);
  border-color: var(--pt-accent);
  background: var(--pt-accent-soft);
}

.preserve-lines {
  white-space: pre-line;
}

.markdown-body {
  line-height: 1.6;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.25em 0 0.5em;
  font-weight: 600;
  line-height: 1.3;
}

.markdown-body h1 { font-size: 1.5rem; }
.markdown-body h2 { font-size: 1.25rem; }
.markdown-body h3 { font-size: 1.1rem; }
.markdown-body h4 { font-size: 1rem; }

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body table {
  margin: 0 0 0.75em;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.5em;
}

.markdown-body li + li {
  margin-top: 0.25em;
}

.markdown-body blockquote {
  padding-left: 1em;
  border-left: 3px solid var(--pt-border-strong);
  color: var(--pt-text-muted);
}

.markdown-body code {
  padding: 0.15em 0.35em;
  border-radius: 0.25rem;
  background: var(--pt-bg);
  font-size: 0.9em;
}

.markdown-body pre {
  padding: 0.75rem 1rem;
  border-radius: var(--pt-radius);
  background: var(--pt-bg);
  overflow-x: auto;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
}

.markdown-body a {
  color: var(--pt-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.markdown-body a:hover {
  color: var(--pt-primary-hover);
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}

.markdown-body th,
.markdown-body td {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--pt-border);
}

.markdown-body th {
  background: var(--pt-bg);
  font-weight: 600;
  text-align: left;
}

.markdown-body input[type="checkbox"] {
  margin-right: 0.35em;
  vertical-align: middle;
}

.screenshot-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.screenshot-gallery--compact {
  gap: 0.5rem;
}

.screenshot-gallery-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0;
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius);
  background: var(--pt-surface);
  cursor: zoom-in;
  overflow: hidden;
  max-width: 160px;
  text-align: left;
}

.screenshot-gallery-item:hover {
  border-color: #93c5fd;
  box-shadow: var(--pt-shadow-sm);
}

.screenshot-gallery-item:focus-visible {
  outline: none;
  box-shadow: var(--pt-focus);
}

.screenshot-gallery-thumb {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}

.screenshot-gallery--compact .screenshot-gallery-thumb {
  width: 88px;
  height: 66px;
}

.screenshot-gallery--compact .screenshot-gallery-item {
  max-width: 88px;
}

.screenshot-gallery-label {
  font-size: 0.7rem;
  color: var(--pt-text-muted);
  padding: 0 0.45rem 0.45rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screenshot-gallery--compact .screenshot-gallery-label {
  display: none;
}

.screenshot-gallery-item-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.screenshot-delete-form {
  padding: 0 0.25rem 0.25rem;
}

/* ── Danger zone (destructive actions) ── */
.danger-zone {
  border: 1px solid #fecaca;
  background: #fef2f2;
}

.danger-zone-title {
  font-size: 1rem;
  font-weight: 600;
  color: #b91c1c;
  margin-bottom: 0.5rem;
}

.danger-zone .form-control {
  max-width: 24rem;
}

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

/* ── Login ── */
.login-body {
  background: linear-gradient(160deg, var(--pt-nav-bg) 0%, #1e3a5f 45%, var(--pt-bg) 100%);
}

.login-main {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  width: 100%;
  max-width: 26rem;
  padding: 2rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand .app-brand-icon {
  display: inline-flex;
  margin-bottom: 0.75rem;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.login-subtitle {
  font-size: 0.95rem;
  margin-bottom: 0;
}

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  margin-bottom: 0;
  font-size: 0.9rem;
}

.nav-user-label {
  font-size: 0.875rem;
  cursor: default;
}

.nav-signout {
  border: none;
  background: none;
  padding: 0.5rem 1rem;
  color: var(--pt-nav-text) !important;
}

.nav-signout:hover {
  color: var(--pt-nav-active) !important;
}
