/* 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, .badge-rolling_back, .badge-deploying {
  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, .badge-rollback_failed {
  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(1120px, 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;
}

/* ---------- "Everything in PDF" checkbox ---------- */
.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-weight: 400;
  cursor: pointer;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.checkbox-row input { margin-top: 2px; flex: 0 0 auto; }
textarea.dimmed { opacity: 0.55; }

/* ---------- Two-zone upload grid ---------- */
.dz-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 620px) { .dz-grid { grid-template-columns: 1fr; } }
.dz-col { min-width: 0; }
.dz-title { font-weight: 600; margin-bottom: 2px; }
#uploadError:empty { display: none; }
#uploadError { color: var(--danger); font-weight: 500; }

/* ---------- Login / admin extras ---------- */
.alert-info { background: var(--badge-blue-bg); color: var(--badge-blue-fg); border-radius: 8px; padding: 10px 12px; }
.badge-green { background: var(--badge-green-bg); color: var(--badge-green-fg); }

.req-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.req-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.req-note { margin: 4px 0 8px; font-style: italic; }
.req-form { margin: 6px 0; }
.req-actions { margin-top: 8px; }
.proj-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 6px 0; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.chk input { flex: 0 0 auto; }

.user-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.user-table th, .user-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.user-table th { color: var(--muted); font-weight: 600; }

/* submitted = awaiting admin run */
.badge-submitted { background: var(--badge-blue-bg); color: var(--badge-blue-fg); }

/* ---------- Ticket view / edit ---------- */
.btn-secondary { background: var(--surface); color: var(--primary); border: 1px solid var(--primary); }
.btn-secondary:hover { background: var(--badge-blue-bg); }
.btn-xs { padding: 2px 8px; font-size: 0.78rem; }
.field-block h3 { font-size: 0.95rem; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.field-text { white-space: pre-wrap; word-wrap: break-word; line-height: 1.5; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.att-tile {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: var(--bg);
}
.att-tile:hover { border-color: var(--primary); }
.att-tile img { width: 100%; height: 120px; object-fit: cover; border-radius: 5px; display: block; }
.att-pdf { height: 120px; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--danger); background: var(--surface); border-radius: 5px; }
.att-name { font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item.removed { opacity: 0.5; }
.file-item.removed .file-name { text-decoration: line-through; }
.saved-tag { font-size: 0.72rem; color: var(--muted); background: var(--badge-grey-bg); border-radius: 999px; padding: 1px 7px; }
.saved-tag.new { color: var(--badge-green-fg); background: var(--badge-green-bg); }

/* ---------- Two-zone alignment: share rows across columns (subgrid) ---------- */
.dz-col > .dz-title { margin: 0 0 2px; }
.dz-col > .hint { margin: 0 0 8px; }
.dz-col > .file-list { margin-top: 8px; }
@supports (grid-template-rows: subgrid) {
  .dz-grid { grid-template-rows: repeat(5, auto); row-gap: 0; column-gap: 16px; }
  .dz-col { display: grid; grid-row: span 5; grid-template-rows: subgrid; align-content: start; }
}
@media (max-width: 620px) {
  .dz-grid { display: block; }
  .dz-col { display: block; margin-bottom: 16px; }
}

/* ---------- Gallery (lightbox prev / next) ---------- */
.gal-box { position: relative; }
.gal-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 1.9rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 3;
}
.gal-nav:hover { background: rgba(0, 0, 0, 0.7); }
.gal-nav[hidden] { display: none; }
.gal-prev { left: 10px; }
.gal-next { right: 10px; }
.report-attachments .report-img:hover { outline: 2px solid var(--primary); }

/* Gallery: disabled arrows at the ends + group tag in the title */
.gal-nav:disabled { opacity: 0.25; cursor: default; background: rgba(0, 0, 0, 0.35); }
.gal-nav:disabled:hover { background: rgba(0, 0, 0, 0.35); }
.gal-group {
  display: inline-block; font-size: 0.75rem; font-weight: 600; border-radius: 999px;
  padding: 1px 9px; margin-right: 8px; vertical-align: middle;
}
.gal-group-origin { background: var(--badge-amber-bg); color: var(--badge-amber-fg); }
.gal-group-reference { background: var(--badge-blue-bg); color: var(--badge-blue-fg); }

/* Destructive secondary action (Delete) */
.btn-danger-outline { background: var(--surface); color: var(--danger); border: 1px solid var(--danger); }
.btn-danger-outline:hover { background: var(--badge-red-bg); }

/* ---------- TICKET.md / RESULT.md reader ---------- */
.md-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px; }
.md-doc-tabs { margin: 0; }
.md-doc-tabs .tab-btn { text-decoration: none; }
.md-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.md-doc { padding: 22px 26px; }
.md-meta { border-collapse: collapse; font-size: 0.85rem; margin-bottom: 16px; }
.md-meta th { text-align: left; color: var(--muted); font-weight: 600; padding: 3px 14px 3px 0; white-space: nowrap; }
.md-meta td { padding: 3px 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }
.md-body { line-height: 1.6; }
.md-body h1 { font-size: 1.45rem; margin: 0 0 12px; }
.md-body h2 { font-size: 1.12rem; margin: 22px 0 8px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.md-body h3 { font-size: 1rem; margin: 16px 0 6px; }
.md-body p, .md-body ul, .md-body ol { margin: 6px 0; }
.md-body ul, .md-body ol { padding-left: 22px; }
.md-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.86em;
  background: var(--badge-grey-bg); color: var(--badge-grey-fg); padding: 1px 5px; border-radius: 4px; }
.md-body pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow: auto; }
.md-body pre code { background: none; padding: 0; }
.md-body blockquote { margin: 8px 0; padding: 6px 14px; border-left: 4px solid var(--badge-amber-fg); background: var(--badge-amber-bg); border-radius: 0 6px 6px 0; }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
.md-body img.md-img { max-width: 100%; max-height: 360px; border: 1px solid var(--border); border-radius: 8px; margin: 6px 0; cursor: zoom-in; display: block; }
.md-table { border-collapse: collapse; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 5px 9px; }

/* ---------- Slim ticket list (Pending / submissions tabs) ---------- */
[hidden] { display: none !important; }
.btn-xs { padding: 0.22rem 0.55rem; font-size: 0.8rem; border-radius: 6px; line-height: 1.3; }
.ticket-list { padding: 0; overflow: hidden; }
.ticket-list.loading .tl-rows { opacity: 0.55; transition: opacity 0.15s; }
.tl-toolbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border);
}
.tl-search {
  flex: 1; min-width: 0; padding: 0.45rem 0.7rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: inherit; font: inherit;
}
.tl-search:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.tl-range { font-size: 0.85rem; white-space: nowrap; }
.tl-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.9rem; border-bottom: 1px solid var(--border);
  font-size: 0.92rem; min-height: 2.5rem;
}
.tl-row:last-child { border-bottom: 0; }
.tl-row:hover { background: var(--surface-2); }
.tl-row .badge { flex: none; font-size: 0.72rem; padding: 0.1rem 0.45rem; }
.tl-id { flex: none; width: 3.2rem; font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.tl-title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: inherit; text-decoration: none; font-weight: 500;
}
.tl-title:hover { text-decoration: underline; }
.tl-meta { flex: none; display: flex; gap: 0.7rem; font-size: 0.8rem; white-space: nowrap; }
.tl-who { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
.tl-date { font-variant-numeric: tabular-nums; }
.tl-actions { flex: none; display: flex; gap: 0.3rem; align-items: center; }
.tl-actions form { margin: 0; display: inline; }
.tl-empty { padding: 1.4rem 0.9rem; text-align: center; margin: 0; }
.tl-pager {
  display: flex; justify-content: center; align-items: center; gap: 0.8rem;
  padding: 0.55rem; border-top: 1px solid var(--border); font-size: 0.85rem;
}
.tl-pager .btn:disabled { opacity: 0.4; cursor: default; }
@media (max-width: 720px) {
  .tl-row { flex-wrap: wrap; row-gap: 0.3rem; }
  .tl-title { flex-basis: calc(100% - 9rem); }
  .tl-meta { flex: 1; }
  .tl-who { max-width: 9rem; }
}

/* ---------- @ references to attachments ---------- */
.mention-box {
  position: absolute; z-index: 60; min-width: 240px; max-width: 320px; max-height: 240px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); padding: 4px;
}
.mention-item { display: flex; align-items: center; gap: 0.55rem; padding: 0.35rem 0.5rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem; }
.mention-item.active, .mention-item:hover { background: var(--surface-2); }
.mention-thumb {
  flex: none; width: 32px; height: 32px; border-radius: 4px; overflow: hidden; display: grid; place-items: center;
  background: var(--surface-2); font-size: 0.65rem; font-weight: 700; color: #c0392b;
}
.mention-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mention-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-group { flex: none; font-size: 0.72rem; color: var(--muted); }
.mention-empty { padding: 0.5rem 0.6rem; font-size: 0.85rem; color: var(--muted); }
.mention-ref {
  display: inline; padding: 0 0.3em; margin: 0; border: 0; border-radius: 4px; font: inherit;
  background: var(--badge-blue-bg, rgba(47, 111, 235, 0.12)); color: var(--primary); cursor: pointer; text-decoration: none;
}
.mention-ref:hover { text-decoration: underline; }
