/* self-help-ops — clean, friendly, light + dark aware */

:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1c2430;
  --muted: #5c6773;
  --border: #dfe3e8;
  --primary: #2f6feb;
  --primary-hover: #2559c4;
  --success: #1f9d57;
  --success-hover: #178048;
  --danger: #d64545;
  --danger-hover: #b83636;
  --focus: #2f6feb;

  /* status badge colors */
  --badge-amber-bg: #fff3d6;   --badge-amber-fg: #7a5300;
  --badge-blue-bg: #dceaff;    --badge-blue-fg: #1b4fa8;
  --badge-green-bg: #d8f3e2;   --badge-green-fg: #14663b;
  --badge-grey-bg: #e6e9ee;    --badge-grey-fg: #4a5561;
  --badge-red-bg: #ffdedc;     --badge-red-fg: #9a2b2b;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06), 0 2px 8px rgba(20, 30, 45, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181e;
    --surface: #1d232c;
    --surface-2: #262d38;
    --text: #e6eaf0;
    --muted: #9aa5b1;
    --border: #333c48;
    --primary: #5a8bf5;
    --primary-hover: #6f9bf7;
    --success: #38b672;
    --success-hover: #45c580;
    --danger: #e56a6a;
    --danger-hover: #ef7d7d;
    --focus: #5a8bf5;

    --badge-amber-bg: #3d3113;   --badge-amber-fg: #f0c874;
    --badge-blue-bg: #1c2f4d;    --badge-blue-fg: #9cc0ff;
    --badge-green-bg: #143a28;   --badge-green-fg: #7fe0aa;
    --badge-grey-bg: #2c333d;    --badge-grey-fg: #aeb8c4;
    --badge-red-bg: #4a1f1f;     --badge-red-fg: #f2a3a3;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Header / footer ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.header-nav { display: flex; gap: 1rem; align-items: center; }
.logout-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}
.logout-link:hover { color: var(--text); text-decoration: underline; }

.app-main {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 2.5rem;
}

.app-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
.app-footer p { margin: 0; }

/* ---------- Layout helpers ---------- */
.stack > * + * { margin-top: 1.1rem; }
.page-head h1, .page-head h2 { margin: 0 0 0.15rem; }
.muted { color: var(--muted); }
.hint { font-size: 0.85rem; }

h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }

.url-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-2);
  padding: 0.1em 0.4em;
  border-radius: 5px;
  font-size: 0.9em;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
}
.card h2:first-child, .card h1:first-child { margin-top: 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.project-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.project-card h2 { margin: 0 0 0.35rem; }
.project-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.empty-state { text-align: center; color: var(--muted); }
.empty-state h1 { color: var(--text); }

/* ---------- Forms ---------- */
label { font-weight: 600; font-size: 0.92rem; }
input[type="text"], input[type="password"], input[type="file"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
input[type="file"] { padding: 0.5rem; }
input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

.upload-form label + input { margin-top: 0.25rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.05rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }

/* ---------- Alerts ---------- */
.alert {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.92rem;
}
.alert-error {
  background: var(--badge-red-bg);
  color: var(--badge-red-fg);
  border: 1px solid var(--badge-red-fg);
}

/* ---------- Login ---------- */
.login-wrap {
  display: flex;
  justify-content: center;
  padding-top: 2rem;
}
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { margin-top: 0; }

/* ---------- Status badges ---------- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
  background: var(--badge-grey-bg);
  color: var(--badge-grey-fg);
}
/* amber */
.badge-queued, .badge-running, .badge-fixing {
  background: var(--badge-amber-bg); color: var(--badge-amber-fg);
}
/* blue */
.badge-committed, .badge-fixed {
  background: var(--badge-blue-bg); color: var(--badge-blue-fg);
}
/* green */
.badge-pushed {
  background: var(--badge-green-bg); color: var(--badge-green-fg);
}
/* grey */
.badge-rolled_back, .badge-open {
  background: var(--badge-grey-bg); color: var(--badge-grey-fg);
}
/* red */
.badge-failed, .badge-session_unavailable {
  background: var(--badge-red-bg); color: var(--badge-red-fg);
}

/* ---------- Submission cards ---------- */
.submission-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.submission-date { font-size: 0.85rem; }
.submission-body { margin-top: 0.75rem; }

.pdf-names {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.5rem;
}
.pdf-chip {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}
.summary { margin: 0; }

.submission-details {
  margin-top: 0.9rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.submission-details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  list-style-position: inside;
}
.submission-details > summary:hover { color: var(--text); }
.details-body { margin-top: 0.65rem; }
.detail-link {
  color: var(--primary);
  font-size: 0.9rem;
  text-decoration: none;
}
.detail-link:hover { text-decoration: underline; }

.submission-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.submission-actions form { margin: 0; }

/* ---------- Bug list ---------- */
.bug-list { list-style: none; margin: 0; padding: 0; }
.bug-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.bug-item:last-child { border-bottom: none; }
.bug-title { font-weight: 500; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.tab-btn {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.tab-count {
  background: var(--badge-grey-bg);
  color: var(--badge-grey-fg);
  border-radius: 999px;
  font-size: 0.75rem;
  padding: 1px 8px;
  font-weight: 600;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel > * + * { margin-top: 20px; }

/* ---------- Drag & drop upload ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover { border-color: var(--primary); }
.dropzone:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--badge-blue-bg);
}
.dropzone-icon { font-size: 1.8rem; line-height: 1; display: block; color: var(--primary); }
.dropzone-text { margin: 8px 0 2px; }

.file-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
}
.file-remove {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.file-remove:hover { color: var(--danger-hover); }

/* ---------- Textarea ---------- */
textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 84px;
}
textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- Keyboard hint ---------- */
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8em;
  background: var(--badge-grey-bg);
  color: var(--badge-grey-fg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}

/* ---------- File thumbnails ---------- */
.file-item { gap: 10px; }
.file-thumb {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  cursor: pointer;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb-pdf { font-size: 0.7rem; font-weight: 700; color: var(--danger); letter-spacing: 0.03em; }
.file-thumb:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.file-name { flex: 1 1 auto; cursor: pointer; }
.file-name:hover { text-decoration: underline; }

/* ---------- Preview modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: min(1000px, 96vw);
  max-height: 92vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-caption { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-content {
  padding: 12px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.modal-content img { max-width: 100%; max-height: 82vh; object-fit: contain; border-radius: 6px; }
.pdf-frame { width: min(900px, 90vw); height: 80vh; border: none; background: #fff; }

/* ---------- Review page ---------- */
.notice { border-left: 4px solid var(--border); }
.notice-ok { border-left-color: var(--success); }
.notice-warn { border-left-color: var(--badge-amber-fg); }
.question-list { margin: 8px 0 14px; padding-left: 20px; }
.question-list li { margin: 4px 0; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.report-md {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  max-height: 60vh;
  overflow: auto;
}
.review-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn-plain {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-plain:hover { color: var(--text); }

/* ---------- Extra status badges ---------- */
.badge-review { background: var(--badge-amber-bg); color: var(--badge-amber-fg); }
.badge-cancelled { background: var(--badge-grey-bg); color: var(--badge-grey-fg); }
.badge-needs_info { background: var(--badge-amber-bg); color: var(--badge-amber-fg); }

/* ---------- Report review modal ---------- */
.modal-report { max-width: min(820px, 96vw); }
.modal-head-actions { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  padding: 4px 9px;
  font-size: 0.8rem;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn-label { font-weight: 600; }
.modal-foot {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.report-render {
  display: block;
  text-align: left;
  line-height: 1.55;
  padding: 18px 20px;
}
.report-render h1 { font-size: 1.3rem; margin: 0 0 8px; }
.report-render h2 { font-size: 1.08rem; margin: 16px 0 6px; }
.report-render h3 { font-size: 0.98rem; margin: 14px 0 4px; color: var(--muted); }
.report-render p { margin: 6px 0; }
.report-render ul { margin: 6px 0 6px 4px; padding-left: 20px; }
.report-render li { margin: 3px 0; }
.report-render code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--badge-grey-bg);
  color: var(--badge-grey-fg);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------- Required marker ---------- */
.req { color: var(--danger); font-weight: 700; }

/* ---------- Report attachments (in modal) ---------- */
.clarify-panel { margin-top: 14px; }
.report-attachments { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.report-attachments h2 { font-size: 1.08rem; margin: 0 0 8px; }
.report-img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 8px 0;
}
