:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body, #root { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.boot { padding: 3rem; color: var(--muted); font-family: var(--font); }

/* ---------------------------------------------------------------- layout */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 16px;
  padding: 4px 8px 18px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: #374151; font-weight: 500; font-size: 13.5px;
}
.nav-item:hover { background: #f3f4f6; text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.nav-spacer { flex: 1; }
.nav-user { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; }
.nav-user-name { font-weight: 600; font-size: 13px; }
.nav-user-email { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 58px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 15px; margin: 0; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { padding: 24px; max-width: 1180px; width: 100%; }

/* ---------------------------------------------------------------- primitives */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 18px; }
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 13px; border-radius: 8px; font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.btn:hover { background: #f9fafb; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-ghost { border-color: transparent; background: transparent; }

.input, .select, .textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.textarea { resize: vertical; min-height: 84px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: #374151; }
.hint { font-size: 12px; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: #f3f4f6; color: #374151; text-transform: capitalize;
}
.badge-open { background: #fef3c7; color: #92400e; }
.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-resolved { background: #d1fae5; color: #065f46; }
.badge-approved { background: #ede9fe; color: #5b21b6; }
.badge-verified { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 14px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafafa; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head h1 { font-size: 22px; margin: 12px 0 4px; letter-spacing: -0.02em; }
.auth-head p { color: var(--muted); margin: 0; font-size: 13.5px; }
.auth-switch { text-align: center; margin-top: 14px; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- misc */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.code-block {
  background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  overflow-x: auto; white-space: pre; line-height: 1.6;
}

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  padding: 9px 13px; font-size: 13px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; cursor: pointer; background: none; border-top: none;
  border-left: none; border-right: none; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 600; flex: 0 0 auto;
}

.feedback-item {
  display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid #f3f4f6;
  cursor: pointer; align-items: flex-start;
}
.feedback-item:hover { background: #fafafa; }
.feedback-item:last-child { border-bottom: none; }

.thread { display: flex; flex-direction: column; gap: 14px; }
.comment { display: flex; gap: 10px; }
.comment-body { background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; flex: 1; }
.comment-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.screenshot {
  width: 100%; border-radius: 8px; border: 1px solid var(--border);
  background: #f3f4f6; display: block;
}

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 100;
  background: #111827; color: #fff; padding: 11px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); max-width: 340px;
}
.toast-error { background: #991b1b; }

.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- review mode */
.review-shell {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; background: #0b1220;
}

.review-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; background: #0f172a; border-bottom: 1px solid #1f2937;
  color: #e5e7eb; flex-wrap: wrap; flex: 0 0 auto;
}
.review-bar-left {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 10px;
}
.review-bar-center { flex: 0 0 auto; display: flex; justify-content: center; }
.review-bar-right {
  flex: 1 1 0; display: flex; align-items: center; justify-content: flex-end;
  gap: 6px; flex-wrap: wrap;
}

/* Primary call to action, centred in the review bar. */
.review-add-main {
  background: var(--brand); color: #fff; border: none; border-radius: 10px;
  padding: 12px 28px; font-size: 14.5px; font-weight: 700; cursor: pointer;
  font-family: inherit; letter-spacing: 0.01em; white-space: nowrap;
  box-shadow: 0 6px 22px rgba(79, 70, 229, 0.5);
  transition: transform 0.12s ease, background 0.12s ease;
}
.review-add-main:hover { background: var(--brand-dark); transform: translateY(-1px); }
.review-add-main:active { transform: translateY(0); }
.review-bar strong { font-size: 13px; }
.review-bar .btn { background: #1e293b; border-color: #334155; color: #e5e7eb; position: relative; }
.review-bar .btn:hover { background: #273449; }
.review-bar .btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.review-bar .btn-primary:hover { background: var(--brand-dark); }
.review-presets { flex-wrap: wrap; gap: 6px; }
/* Live viewport readout, next to the project name. */
.review-dim {
  font-size: 12.5px; font-weight: 600; color: #e5e7eb;
  background: #1e293b; border: 1px solid #334155;
  padding: 4px 10px; border-radius: 999px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* iOS-style count badge on the viewport presets. */
.preset-badge {
  position: absolute; top: -7px; right: -7px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: #dc2626; color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 18px;
  text-align: center; box-shadow: 0 0 0 2px #0f172a;
}

/* Status control at the bottom of the detail panel. */
.status-block {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
}
.status-block-label {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); margin-bottom: 10px;
}

.review-body { flex: 1; display: flex; min-height: 0; }

.review-stage {
  flex: 1; min-width: 0; display: grid; place-items: center;
  padding: 16px; overflow: auto; background: #111827; position: relative;
}

/* ---------------------------------------------------------------- page strip */
.page-strip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: #0f172a;
  border-bottom: 1px solid #1f2937; flex: 0 0 auto;
}
.page-strip .btn { background: #1e293b; border-color: #334155; color: #e5e7eb; }
.page-strip .btn:hover { background: #273449; }

.page-strip-list {
  display: flex; gap: 8px; overflow-x: auto; flex: 1; min-width: 0;
  /* Room for the badge, which overhangs the card by 6px. Without this the
     scroll container clips it. */
  padding: 9px 8px 3px;
  margin: -9px -8px -3px;
}

.page-card {
  display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
  width: 200px; padding: 6px; border-radius: 8px; cursor: pointer;
  background: #1e293b; border: 1px solid #334155; color: #e5e7eb;
  font-family: inherit; text-align: left; position: relative;
}
.page-card:hover { background: #273449; }
.page-card.active { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.35); }

.page-thumb {
  width: 56px; height: 40px; border-radius: 4px; overflow: hidden;
  background: #334155; flex: 0 0 auto; display: block;
}
.page-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.page-title {
  font-size: 11.5px; line-height: 1.25; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

.page-badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: #22c55e; color: #052e16; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 0 0 2px #0f172a;
}
.page-badge-static {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: #22c55e; color: #052e16; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

.page-strip-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

/* Fixed site origin + editable slug. */
.page-url-group {
  display: flex; align-items: center; height: 32px;
  background: #1e293b; border: 1px solid #334155; border-radius: 8px;
  overflow: hidden;
}
.page-url-prefix {
  padding: 0 8px; font-size: 12px; color: #94a3b8;
  border-right: 1px solid #334155; white-space: nowrap;
  max-width: 170px; overflow: hidden; text-overflow: ellipsis;
}
.page-url-group .input {
  width: 150px; height: 100%; border: none; border-radius: 0;
  background: transparent; color: #e5e7eb; font-size: 12.5px;
}
.page-url-group .input:focus { box-shadow: none; }
.page-url-group .input::placeholder { color: #64748b; }

.pages-modal {
  width: 100%; max-width: 560px; max-height: 80vh; overflow-y: auto;
  background: #fff; border-radius: 12px; padding: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.pages-modal-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 8px; cursor: pointer;
}
.pages-modal-row:hover { background: #f3f4f6; }
.pages-modal-row .page-thumb { background: #e5e7eb; }

/* ---------------------------------------------------------------- attachments */
.attach-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attach-thumb {
  width: 56px; height: 56px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: #f3f4f6;
  display: flex; align-items: center; justify-content: center;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-thumb:hover { border-color: var(--brand); }
.file-chip { font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
.review-scaler { position: relative; }
.review-frame {
  transform-origin: top left; background: #fff; overflow: hidden;
  border-radius: 6px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.review-frame iframe { border: 0; display: block; background: #fff; }

.review-panel {
  position: relative;
  width: 25%; min-width: 300px; max-width: 520px; flex: 0 0 auto;
  display: flex; min-height: 0;
}
.review-panel.closed { width: 0; min-width: 0; max-width: 0; }

.review-panel-inner {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-left: 1px solid var(--border);
  overflow: hidden;
}
.review-panel.closed .review-panel-inner { display: none; }

/* Circular chevron pinned to the panel's left edge; stays on screen when hidden. */
.panel-toggle {
  position: absolute; left: -19px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%; padding: 0;
  background: #fff; border: 1px solid var(--border); color: #374151;
  display: grid; place-items: center; font-size: 20px; line-height: 1;
  cursor: pointer; z-index: 80; font-family: inherit;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}
.panel-toggle:hover { background: #f3f4f6; }

/* When the panel is hidden the toggle is the only way back — make it loud. */
.panel-toggle.closed {
  left: -23px; width: 46px; height: 46px;
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 6px 22px rgba(79, 70, 229, 0.55);
}
.panel-toggle.closed:hover { background: var(--brand-dark); }

/* ---------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 23, 42, 0.55);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 420px; background: #fff;
  border-radius: 12px; padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.link-btn {
  background: none; border: none; padding: 0; margin-top: 6px;
  color: var(--red); font-size: 11.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; text-decoration: underline;
}

/* ---------------------------------------------------------------- screenshot */
/* Fixed square preview; the full image opens in the lightbox. */
.shot-thumb {
  display: block; width: 100%; max-width: 500px;
  aspect-ratio: 1 / 1; max-height: 500px;
  padding: 0; overflow: hidden; cursor: zoom-in;
  background: #f3f4f6; border: 1px solid var(--border); border-radius: 8px;
}
.shot-thumb img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.shot-thumb:hover { border-color: var(--brand); }

.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, 0.85);
  display: grid; place-items: center; padding: 24px; cursor: zoom-out;
}
.lightbox img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.16); color: #fff; border: none;
  font-size: 18px; line-height: 1; cursor: pointer; font-family: inherit;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.28); }
.review-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.review-panel-title { font-weight: 700; font-size: 13px; }
.review-panel-sub { font-size: 11.5px; color: var(--muted); }
.review-filters {
  display: flex; gap: 6px; padding: 10px 14px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.review-list { flex: 1; overflow-y: auto; min-height: 0; }
.review-item { padding: 11px 14px; border-bottom: 1px solid #f3f4f6; cursor: pointer; }
.review-item:hover { background: #fafafa; }
.review-item.active { background: var(--brand-soft); }
.review-detail { flex: 1; overflow-y: auto; min-height: 0; padding: 14px; }

.review-float {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  background: var(--brand); color: #fff; border: none; border-radius: 999px;
  padding: 10px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45); font-family: inherit;
}
.review-float:hover { background: var(--brand-dark); }

/* Floating "new feedback" card — sits over the preview, never in the list column. */
.review-form-float {
  position: absolute; left: 24px; bottom: 24px; z-index: 20;
  width: min(400px, calc(100% - 48px));
  max-height: calc(100% - 48px); overflow-y: auto;
  background: #fff; border-radius: 12px; padding: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border);
}

@media (max-width: 1100px) {
  .review-bar-left, .review-bar-right { flex: 1 1 100%; }
  .review-bar-right { justify-content: flex-start; }
  .review-bar-center { flex: 1 1 100%; order: -1; }
  .review-add-main { width: 100%; }
}

@media (max-width: 900px) {
  .review-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
    width: min(88vw, 380px); max-width: none;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.3);
  }
  .review-stage { padding: 8px; }
  .review-bar { padding: 8px 10px; }
}
