:root {
  --accent: #4353ff;
  --accent-soft: #eef0ff;
  --ink: #1f2430;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e8eaf0;
  --bg: #f7f8fb;
  --card: #ffffff;
  --red: #d92d20;
  --green: #12b76a;
  --amber: #f79009;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 12px 26px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-size: 16px; font-weight: 700; color: var(--ink); }
.brand:hover { text-decoration: none; }
.topbar-sub { color: var(--faint); font-size: 12.5px; }

#app { max-width: 1160px; margin: 0 auto; padding: 26px; }
.loading { color: var(--muted); padding: 40px; text-align: center; }

.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; font-weight: 700; flex: 1; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 8px 14px; font: 600 13.5px/1.2 inherit;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px 20px;
}

/* ---- projects grid ---- */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.project-card { display: block; color: inherit; transition: box-shadow .15s ease, transform .15s ease; }
.project-card:hover { text-decoration: none; box-shadow: 0 8px 24px rgba(15,23,42,.09); transform: translateY(-1px); }
.project-card h3 { font-size: 15.5px; margin-bottom: 4px; }
.project-card .pkey { font-size: 12px; color: var(--faint); font-family: ui-monospace, Consolas, monospace; }
.project-card .counts { margin-top: 12px; display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.project-card .counts b { color: var(--ink); }

/* ---- forms ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 650; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.field input[type="text"], .field input[type="email"], .field textarea, .field select {
  width: 100%; border: 1px solid #d5d9e4; border-radius: 8px; padding: 8px 10px;
  font: inherit; color: inherit; background: #fff;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid #c3c9ff; border-color: var(--accent); }
.field input[type="color"] { border: 1px solid #d5d9e4; border-radius: 8px; height: 38px; width: 60px; padding: 3px; background: #fff; cursor: pointer; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; flex: 1; min-width: 200px; }

/* ---- filter bar & table ---- */
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters select, .filters input {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font: inherit; background: #fff;
}
.filters input { flex: 1; min-width: 180px; }

table.issues { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table.issues { display: block; overflow-x: auto; }
table.issues thead, table.issues tbody { display: table; width: 100%; table-layout: fixed; }
table.issues th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfcfe; }
table.issues td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.issues tbody tr { cursor: pointer; }
table.issues tbody tr:hover { background: #fafbff; }
table.issues tbody tr:last-child td { border-bottom: 0; }
.col-num { width: 56px; color: var(--faint); }
.col-type { width: 46px; font-size: 16px; text-align: center; }
.col-pill { width: 105px; }
.col-date { width: 120px; color: var(--muted); font-size: 12.5px; }
.col-reporter { width: 150px; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.title-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
td.title-cell .cc { color: var(--faint); font-weight: 400; font-size: 12px; margin-left: 6px; }

.pill { display: inline-block; border-radius: 999px; padding: 2.5px 10px; font-size: 11.5px; font-weight: 650; }
.pill.status-open { background: #eef4ff; color: #175cd3; }
.pill.status-in_progress { background: #fef4e6; color: #b54708; }
.pill.status-resolved { background: #ecfdf3; color: #067647; }
.pill.status-closed { background: #f2f4f7; color: #475467; }
.pill.pri-low { background: #f2f4f7; color: #475467; }
.pill.pri-medium { background: #eef4ff; color: #175cd3; }
.pill.pri-high { background: #fef4e6; color: #b54708; }
.pill.pri-critical { background: #fee4e2; color: #b42318; }

.empty { text-align: center; color: var(--muted); padding: 46px 20px; background: #fff; border: 1px dashed var(--line); border-radius: 12px; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { padding: 9px 16px; border: 0; background: none; font: 600 13.5px/1 inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- issue detail ---- */
.issue-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .issue-layout { grid-template-columns: 1fr; } }
.issue-title { font-size: 19px; font-weight: 700; margin-bottom: 2px; }
.issue-desc { white-space: pre-wrap; color: var(--ink); margin: 10px 0 0; }
.issue-desc.none { color: var(--faint); font-style: italic; }
.shot-wrap { margin-top: 14px; }
.shot-wrap img { max-width: 100%; border: 1px solid var(--line); border-radius: 10px; cursor: zoom-in; display: block; }
.side-block { margin-bottom: 16px; }
.side-block h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin-bottom: 8px; }
.kv { width: 100%; font-size: 13px; }
.kv td { padding: 3.5px 0; vertical-align: top; }
.kv td:first-child { color: var(--muted); width: 42%; padding-right: 8px; }
.kv td:last-child { word-break: break-word; }
.side-selects { display: flex; flex-direction: column; gap: 8px; }
.side-selects select { width: 100%; border: 1px solid #d5d9e4; border-radius: 8px; padding: 7px 10px; font: inherit; background: #fff; }

.logbox { background: #10141f; color: #d3dae6; border-radius: 10px; padding: 12px 14px; font: 12px/1.6 ui-monospace, Consolas, monospace; max-height: 300px; overflow: auto; }
.logline { white-space: pre-wrap; word-break: break-word; }
.logline .lvl { font-weight: 700; margin-right: 6px; }
.logline.error .lvl, .logline.error { color: #ff8080; }
.logline.warn .lvl, .logline.warn { color: #ffd479; }
.logline .lts { color: #5b6577; margin-right: 8px; }

details.logs { margin-top: 14px; }
details.logs summary { cursor: pointer; font-weight: 650; font-size: 13px; color: var(--muted); padding: 6px 0; }
details.logs summary:hover { color: var(--ink); }

/* ---- comments ---- */
.comment { border-top: 1px solid var(--line); padding: 12px 0; }
.comment .who { font-weight: 650; font-size: 13px; }
.comment .when { color: var(--faint); font-size: 12px; margin-left: 8px; }
.comment .body { margin-top: 4px; white-space: pre-wrap; }
.comment-form { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.comment-form textarea { min-height: 70px; resize: vertical; border: 1px solid #d5d9e4; border-radius: 8px; padding: 8px 10px; font: inherit; }
.comment-form .row { display: flex; gap: 8px; }
.comment-form input { flex: 1; border: 1px solid #d5d9e4; border-radius: 8px; padding: 7px 10px; font: inherit; }

/* ---- snippet ---- */
.snippet { background: #10141f; color: #d3dae6; border-radius: 10px; padding: 14px 16px; font: 12.5px/1.6 ui-monospace, Consolas, monospace; overflow-x: auto; white-space: pre; position: relative; }
.snippet .hl { color: #7ee787; }
.copy-btn { position: absolute; top: 10px; right: 10px; }

/* ---- lightbox ---- */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.85); display: flex; align-items: center; justify-content: center; padding: 30px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

.toast-note { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 9px; font-size: 13px; z-index: 120; box-shadow: 0 10px 30px rgba(15,23,42,.4); }

/* ---- integration banners & toggles ---- */
.banner { border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; line-height: 1.7; }
.banner.ok { background: #ecfdf3; color: #067647; border: 1px solid #a6f4c5; }
.banner.warn { background: #fffaeb; color: #b54708; border: 1px solid #fedf89; }
.banner code { background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 4px; font-size: 12px; word-break: break-all; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; margin-bottom: 8px; cursor: pointer; }
.check input { margin-top: 2px; accent-color: var(--accent); }
.form-error { color: var(--red); font-size: 12.5px; margin-bottom: 10px; }

.muted { color: var(--muted); }
.mt { margin-top: 16px; }
