/* ─────────────────────────────────────────
   TAP Previews — Admin (Design System)
   ───────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Tokens (Light default) ─── */
:root {
  /* surfaces */
  --bg-base:      hsl(220, 22%, 98%);
  --bg-surface:   hsl(0, 0%, 100%);
  --bg-subtle:    hsl(220, 18%, 96%);
  --bg-sidebar:   hsl(220, 20%, 99%);
  --bg-elevated:  hsl(0, 0%, 100%);
  --bg-hover:     hsla(230, 20%, 55%, 0.06);
  --bg-hover-strong: hsla(230, 20%, 55%, 0.1);

  /* borders */
  --border-subtle:  hsla(220, 18%, 20%, 0.08);
  --border-medium:  hsla(220, 18%, 20%, 0.14);
  --border-strong:  hsla(220, 18%, 20%, 0.22);

  /* text */
  --text-primary:   hsl(220, 25%, 14%);
  --text-secondary: hsl(220, 15%, 36%);
  --text-muted:     hsl(220, 10%, 54%);
  --text-placeholder: hsl(220, 10%, 64%);

  /* accents */
  --accent:         hsl(238, 62%, 52%);
  --accent-hover:   hsl(238, 62%, 46%);
  --accent-soft:    hsla(238, 62%, 52%, 0.1);
  --accent-softer:  hsla(238, 62%, 52%, 0.04);
  --accent-fg:      hsl(0, 0%, 100%);
  --accent-ring:    hsla(238, 62%, 52%, 0.22);

  --teal:           hsl(186, 72%, 38%);
  --teal-soft:      hsla(186, 72%, 38%, 0.12);
  --success:        hsl(152, 62%, 38%);
  --success-soft:   hsla(152, 62%, 38%, 0.12);
  --danger:         hsl(0, 68%, 50%);
  --danger-soft:    hsla(0, 68%, 50%, 0.1);
  --warning:        hsl(32, 92%, 46%);
  --warning-soft:   hsla(32, 92%, 46%, 0.12);

  /* typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* shadows */
  --shadow-sm:  0 1px 2px hsla(220, 25%, 14%, 0.05);
  --shadow-md:  0 4px 12px hsla(220, 25%, 14%, 0.06), 0 1px 3px hsla(220, 25%, 14%, 0.04);
  --shadow-lg:  0 12px 36px hsla(220, 25%, 14%, 0.1), 0 2px 6px hsla(220, 25%, 14%, 0.05);
  --shadow-xl:  0 24px 64px hsla(220, 25%, 14%, 0.15);

  /* radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* transitions */
  --t-fast: 140ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-med:  240ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Dark theme overrides ─── */
body.theme-dark {
  --bg-base:      hsl(222, 22%, 8%);
  --bg-surface:   hsl(222, 18%, 11%);
  --bg-subtle:    hsl(222, 16%, 14%);
  --bg-sidebar:   hsl(222, 22%, 9%);
  --bg-elevated:  hsl(222, 16%, 15%);
  --bg-hover:     hsla(230, 20%, 80%, 0.06);
  --bg-hover-strong: hsla(230, 20%, 80%, 0.1);

  --border-subtle:  hsla(220, 15%, 70%, 0.08);
  --border-medium:  hsla(220, 15%, 70%, 0.14);
  --border-strong:  hsla(220, 15%, 70%, 0.22);

  --text-primary:   hsl(220, 15%, 94%);
  --text-secondary: hsl(220, 12%, 72%);
  --text-muted:     hsl(220, 10%, 52%);
  --text-placeholder: hsl(220, 10%, 40%);

  --accent:         hsl(238, 80%, 68%);
  --accent-hover:   hsl(238, 80%, 74%);
  --accent-soft:    hsla(238, 80%, 68%, 0.15);
  --accent-softer:  hsla(238, 80%, 68%, 0.06);
  --accent-fg:      hsl(222, 22%, 10%);
  --accent-ring:    hsla(238, 80%, 68%, 0.32);

  --teal:           hsl(186, 72%, 58%);
  --teal-soft:      hsla(186, 72%, 58%, 0.15);
  --success:        hsl(152, 62%, 54%);
  --success-soft:   hsla(152, 62%, 54%, 0.15);
  --danger:         hsl(0, 72%, 62%);
  --danger-soft:    hsla(0, 72%, 62%, 0.15);
  --warning:        hsl(32, 92%, 60%);
  --warning-soft:   hsla(32, 92%, 60%, 0.15);

  --shadow-sm:  0 1px 2px hsla(0, 0%, 0%, 0.3);
  --shadow-md:  0 4px 12px hsla(0, 0%, 0%, 0.35);
  --shadow-lg:  0 12px 36px hsla(0, 0%, 0%, 0.45);
  --shadow-xl:  0 24px 64px hsla(0, 0%, 0%, 0.55);
}

/* ─── Base ─── */
html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.005em;
}

.mono { font-family: var(--font-mono); font-size: 0.92em; }

/* ─── View switching ─── */
body[data-view="login"] #app-shell { display: none; }
body[data-view="login"] #login-view { display: flex; }
body[data-view="login"] #upload-modal { display: none; }

body[data-view="dashboard"] #login-view,
body[data-view="detail"] #login-view,
body[data-view="activity"] #login-view,
body[data-view="team"] #login-view,
body[data-view="help"] #login-view { display: none; }

.view { display: none; flex: 1; overflow-y: auto; overflow-x: hidden; padding: 32px 40px 48px; max-width: 1400px; width: 100%; margin: 0 auto; }
body[data-view="dashboard"] .view-dashboard,
body[data-view="detail"] .view-detail,
body[data-view="activity"] .view-activity,
body[data-view="team"] .view-team,
body[data-view="help"] .view-help { display: block; }

/* ─── Login ─── */
#login-view {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--bg-base) 0%, var(--bg-subtle) 100%);
  padding: 40px 20px;
  z-index: 100;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.brand-mark.sm { width: 26px; height: 26px; border-radius: var(--r-sm); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-primary { font-weight: 700; font-size: 14px; letter-spacing: 0.3px; color: var(--text-primary); }
.brand-secondary { font-size: 12px; color: var(--text-muted); font-weight: 500; letter-spacing: 0.1px; }

.login-title { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 4px; }
.login-subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 28px; line-height: 1.5; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-actions { font-size: 13px; color: var(--text-secondary); }
.checkbox { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.checkbox input { cursor: pointer; accent-color: var(--accent); }

.login-footer {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}
.link { color: var(--accent); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

.theme-toggle-floating {
  position: fixed;
  top: 20px; right: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--t-fast);
}
.theme-toggle-floating:hover { color: var(--text-primary); border-color: var(--border-medium); }

.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }
body.theme-dark .theme-icon-sun { display: block; }
body.theme-dark .theme-icon-moon { display: none; }

/* ─── Fields ─── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.1px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.field-hint { font-weight: 400; color: var(--text-muted); font-size: 11px; }
.field-help { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.field input[type="email"],
.field input[type="text"],
.field input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-sm);
  outline: none;
  transition: all var(--t-fast);
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.field input::placeholder { color: var(--text-placeholder); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.slug-input, .pw-input {
  display: flex;
  align-items: stretch;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-sm);
  overflow: hidden;
  transition: all var(--t-fast);
}
.slug-input:focus-within, .pw-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.slug-input input, .pw-input input {
  flex: 1;
  border: none !important;
  box-shadow: none !important;
  padding: 10px 8px;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
}
.slug-input input:focus, .pw-input input:focus { box-shadow: none !important; }
.slug-prefix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 12px;
  border-right: 1px solid var(--border-subtle);
}
.slug-input .icon-btn, .pw-input .icon-btn {
  align-self: center;
  margin-right: 6px;
}

.pw-strength {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}
.pw-strength.strong { background: var(--success-soft); color: var(--success); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn.sm { padding: 7px 11px; font-size: 12px; }
.btn-full { width: 100%; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}
.btn-ghost {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-medium);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.btn-danger-ghost {
  background: var(--bg-surface);
  color: var(--danger);
  border-color: var(--border-medium);
}
.btn-danger-ghost:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: all var(--t-fast);
}
.ghost-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.ghost-btn.active { background: var(--bg-subtle); color: var(--text-primary); border-color: var(--border-subtle); }
.ghost-btn.sm { padding: 4px 9px; font-size: 11.5px; }
.panel-dot {
  display: inline-block;
  min-width: 18px;
  padding: 0 4px;
  background: var(--warning-soft);
  color: var(--warning);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  margin-left: 4px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.xs { width: 22px; height: 22px; border-radius: var(--r-xs); }

.link-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--accent-hover); }

/* ─── App shell ─── */
#app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
#sidebar {
  width: 224px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
  height: 62px;
  flex-shrink: 0;
}
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: all var(--t-fast);
}
.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item.active svg { opacity: 1; color: var(--accent); }
.nav-badge {
  margin-left: auto;
  padding: 1px 7px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
}
.nav-item.active .nav-badge {
  background: var(--accent);
  color: var(--accent-fg);
}

.sidebar-bottom {
  padding: 14px;
  border-top: 1px solid var(--border-subtle);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}
.user-chip:hover { background: var(--bg-hover); }
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, hsl(238, 62%, 56%), hsl(280, 55%, 58%));
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* Main */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-base);
}

#topbar {
  height: 62px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-base);
}
.topbar-left { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.crumb { color: var(--text-muted); }
.crumb.active { color: var(--text-primary); font-weight: 500; }
.crumb-sep { color: var(--text-muted); opacity: 0.5; }

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  width: 280px;
  transition: all var(--t-fast);
}
.topbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.topbar-search svg { color: var(--text-muted); flex-shrink: 0; }
.topbar-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
}
.topbar-search input::placeholder { color: var(--text-placeholder); }
.kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
}

/* ─── Page header ─── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.page-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}
.page-subtitle strong { color: var(--text-secondary); font-weight: 600; }

/* ─── Filter bar ─── */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}
.filter-tabs { display: flex; gap: 2px; }
.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: all var(--t-fast);
}
.filter-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.filter-tab.active {
  color: var(--text-primary);
  background: var(--bg-subtle);
  border-color: var(--border-subtle);
}
.filter-count {
  padding: 0 6px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-radius: 9px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 16px;
}
.filter-tab.active .filter-count {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ─── Prototypes table ─── */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.prototypes-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
.prototypes-table th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.prototypes-table th.col-actions { width: 40px; }
.prototypes-table th.col-views { text-align: right; width: 80px; }
.prototypes-table th.col-comments { text-align: right; width: 100px; }
.prototypes-table th.col-created,
.prototypes-table th.col-viewed { width: 140px; }

.prototypes-table td {
  padding: 14px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.prototypes-table tbody tr {
  cursor: pointer;
  transition: background var(--t-fast);
}
.prototypes-table tbody tr:hover { background: var(--bg-hover); }
.prototypes-table tbody tr:last-child td { border-bottom: none; }

.proto-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}
.proto-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, hsl(var(--h, 238), 55%, 48%), hsl(calc(var(--h, 238) + 40), 55%, 56%));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}
.proto-info { min-width: 0; }
.proto-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proto-client {
  font-size: 11.5px;
  color: var(--text-muted);
}

.slug-cell {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}
.slug-cell .slug-prefix-muted {
  color: var(--text-muted);
  opacity: 0.6;
}

.views-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}
.views-cell-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.spark {
  width: 48px;
  height: 18px;
  overflow: visible;
}

.viewed-cell, .created-cell {
  color: var(--text-secondary);
  font-size: 12.5px;
}
.viewed-cell .viewed-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--success);
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.viewed-cell.never { color: var(--text-muted); font-style: italic; }

.comments-cell {
  text-align: right;
  font-size: 12.5px;
}
.comments-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-radius: 10px;
  font-weight: 500;
}
.comments-badge.unresolved {
  background: var(--warning-soft);
  color: var(--warning);
}
.comments-badge.zero { color: var(--text-muted); background: transparent; }

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}

/* ─── Detail view ─── */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
}
.detail-title-row { display: flex; gap: 14px; align-items: flex-start; }
.detail-title-block { display: flex; flex-direction: column; gap: 6px; }
.detail-title-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
}
.muted { color: var(--text-muted); }
.sep { color: var(--text-muted); opacity: 0.5; }
.detail-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.detail-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.status-dot.live {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.detail-actions { display: flex; gap: 8px; }

/* Stat cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  padding: 16px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}
.stat-delta {
  font-size: 12px;
  font-weight: 500;
}
.stat-delta.up { color: var(--success); }
.stat-delta.muted { color: var(--text-muted); }

/* Detail grid */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: flex-start;
}
.detail-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.detail-side { display: flex; flex-direction: column; gap: 18px; }

/* Panels */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}
.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.1px;
}
.panel-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
}
.panel-meta { font-size: 12px; color: var(--text-muted); }
.panel-actions { display: flex; gap: 2px; }
.panel-body { padding: 18px; }
.panel-body-tight { padding: 8px 10px; }

.chart-wrap {
  position: relative;
  width: 100%;
  height: 180px;
}
#views-chart {
  width: 100%;
  height: 100%;
  display: block;
}

/* Comments list */
.comment {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.comment:last-child { border-bottom: none; padding-bottom: 0; }
.comment:first-child { padding-top: 0; }
.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--h1, hsl(186, 60%, 48%)), var(--h2, hsl(220, 60%, 60%)));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.comment-body { flex: 1; min-width: 0; }
.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.comment-author { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.comment-time { font-size: 11.5px; color: var(--text-muted); }
.comment-resolved-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  background: var(--success-soft);
  color: var(--success);
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
}
.comment-unresolved-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  background: var(--warning-soft);
  color: var(--warning);
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
}
.comment-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.55;
  margin-bottom: 6px;
}
.comment-context {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 1px 6px;
  background: var(--bg-subtle);
  border-radius: 4px;
  margin-bottom: 6px;
}
.comment-actions {
  display: flex;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.comment-action {
  background: transparent;
  border: none;
  font: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
}
.comment-action:hover { color: var(--accent); }

/* Share panel */
.share-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border-subtle);
}
.share-row:first-child { padding-top: 0; }
.share-row:nth-last-child(3) { border-bottom: none; padding-bottom: 14px; }
.share-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}
.share-value {
  font-size: 12.5px;
  color: var(--text-primary);
  text-align: right;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pw-mask { letter-spacing: 0.12em; }
.detail-side .panel-body .btn { margin-top: 8px; }
.detail-side .panel-body .btn:first-of-type { margin-top: 12px; }

/* File list */
.file-list { list-style: none; }
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-xs);
  transition: background var(--t-fast);
}
.file-row:hover { background: var(--bg-hover); }
.file-icon { color: var(--text-muted); flex-shrink: 0; }
.file-name { flex: 1; font-size: 12px; color: var(--text-secondary); }
.file-size { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

/* Timeline */
.timeline { list-style: none; position: relative; padding: 6px 6px 6px 14px; }
.timeline::before {
  content: '';
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 20px;
  width: 1px;
  background: var(--border-subtle);
}
.tl-item {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 6px 0;
}
.tl-dot {
  position: relative;
  z-index: 1;
  width: 8px;
  height: 8px;
  background: var(--bg-surface);
  border: 2px solid var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
  margin-left: 2px;
}
.tl-item:nth-child(n+2) .tl-dot { border-color: var(--border-strong); }
.tl-body { min-width: 0; }
.tl-primary { font-size: 12.5px; color: var(--text-primary); line-height: 1.4; }
.tl-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── Activity view ─── */
.activity-feed {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.activity-icon.view { background: var(--accent-soft); color: var(--accent); }
.activity-icon.comment { background: var(--warning-soft); color: var(--warning); }
.activity-icon.create { background: var(--success-soft); color: var(--success); }
.activity-icon.replace { background: var(--teal-soft); color: var(--teal); }
.activity-body { flex: 1; }
.activity-text { font-size: 13px; color: var(--text-primary); line-height: 1.5; }
.activity-text strong { font-weight: 600; }
.activity-text a { color: var(--accent); text-decoration: none; font-weight: 500; }
.activity-time { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* ─── Team view ─── */
.team-list {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.team-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.team-row:last-child { border-bottom: none; }
.team-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.team-info { flex: 1; }
.team-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.team-email { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }
.team-role-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 10px;
}
.team-role-badge.tap { background: var(--accent-soft); color: var(--accent); }
.team-role-badge.fri3nds { background: var(--teal-soft); color: var(--teal); }
.team-last {
  font-size: 12px;
  color: var(--text-muted);
  width: 120px;
  text-align: right;
}

/* ─── Help view ─── */
.help-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.help-card {
  position: relative;
  padding: 22px 22px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.help-num {
  position: absolute;
  top: 18px; right: 20px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
  font-weight: 700;
  font-size: 12px;
}
.help-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  padding-right: 40px;
  letter-spacing: -0.01em;
}
.help-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.help-card code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 1px 6px;
  background: var(--bg-subtle);
  border-radius: 3px;
  color: var(--text-primary);
}

/* ─── Upload modal ─── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: hsla(220, 30%, 10%, 0.5);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  animation: modal-in 220ms ease-out;
}
body.modal-open .modal-backdrop { display: flex; }
body.theme-dark .modal-backdrop { background: hsla(220, 30%, 2%, 0.6); }
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  max-width: 620px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modal-pop 220ms cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modal-pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-body {
  flex: 1;
  padding: 22px;
  overflow-y: auto;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}

/* Upload steps */
.upload-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px dashed var(--border-subtle);
}
.upload-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}
.step-num {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border-subtle);
}
.upload-step.active { color: var(--text-primary); }
.upload-step.active .step-num {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.step-sep {
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
  max-width: 40px;
}

.upload-form { display: flex; flex-direction: column; gap: 16px; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border-medium);
  background: var(--bg-subtle);
  border-radius: var(--r-md);
  padding: 28px 20px;
  text-align: center;
  transition: all var(--t-fast);
  min-height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-softer);
}
.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone-idle, .dropzone-progress, .dropzone-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.dropzone-idle svg { color: var(--text-muted); margin-bottom: 6px; }
.dropzone-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.dropzone-hint { font-size: 12px; color: var(--text-muted); }

.progress-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.progress-bar {
  width: 100%;
  max-width: 360px;
  height: 6px;
  background: var(--bg-hover-strong);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 180ms ease;
}
.progress-meta { font-size: 11.5px; color: var(--text-muted); font-family: var(--font-mono); }

.done-check {
  color: var(--success);
  padding: 6px;
  background: var(--success-soft);
  border-radius: 50%;
  margin-bottom: 4px;
}
.done-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.done-files {
  list-style: none;
  display: flex;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.done-files li {
  padding: 2px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
}
.done-warn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--success);
  margin-top: 4px;
}

/* ─── Toasts ─── */
#toast-area {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  animation: toast-in 240ms ease-out;
  min-width: 260px;
  max-width: 380px;
}
.toast.success { border-color: var(--success); }
.toast.success .toast-icon { color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.error .toast-icon { color: var(--danger); }
.toast-icon { flex-shrink: 0; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── Scrollbars ─── */
.view::-webkit-scrollbar, .modal-body::-webkit-scrollbar { width: 8px; height: 8px; }
.view::-webkit-scrollbar-track, .modal-body::-webkit-scrollbar-track { background: transparent; }
.view::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}
.view::-webkit-scrollbar-thumb:hover, .modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}
