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

:root {
  --bg:        #0f1117;
  --surface:   #1a1d23;
  --border:    #2d3139;
  --text:      #e8eaf0;
  --muted:     #8b8fa8;
  --accent:    #a40901;
  --accent-hov:#c40b01;
  --success:   #2ea043;
  --danger:    #f85149;
  --col-w:     300px;
  --radius:    4px;
  --shadow:    0 2px 6px rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.4);
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
       font-size: 14px; color: var(--text); background: var(--bg); }

.hidden { display: none !important; }

/* ---- Login ---- */
#login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box  { text-align: center; display: flex; flex-direction: column; gap: 16px; }
.login-box h1 { font-size: 24px; }

/* ---- Topbar ---- */
.topbar {
  height: 48px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
  position: sticky; top: 0; z-index: 100;
}
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.scope-filter { display: flex; gap: 4px; }
.type-filter  { display: flex; gap: 4px; }
.topbar-divider { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }
.filter-btn {
  padding: 4px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font: inherit; font-size: 13px;
  color: var(--muted);
}
.filter-btn:hover  { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 16px;
            color: var(--muted); padding: 4px 6px; border-radius: var(--radius); }
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ---- Board ---- */
#board-wrap { overflow-x: auto; height: calc(100vh - 48px); }
#board { display: flex; gap: 12px; padding: 16px; min-height: 100%; width: max-content; }

/* ---- Column ---- */
.col {
  width: var(--col-w); flex-shrink: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; background: var(--surface);
  border-radius: var(--radius); border: 1px solid var(--border);
}
.col-title { font-weight: 600; font-size: 13px; }
.col-count {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 1px 7px; font-size: 12px; color: var(--muted);
}
.col-cards { display: flex; flex-direction: column; gap: 8px; }

/* ---- Issue card ---- */
.issue-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0; cursor: pointer; transition: box-shadow .1s, border-color .1s;
  overflow: hidden;
}
.issue-card:hover { box-shadow: var(--shadow); border-color: var(--muted); }
.card-thumb {
  height: 90px; background: var(--bg) center/contain no-repeat;
  border-bottom: 1px solid var(--border);
}
.card-body { padding: 10px 12px; }
.card-title { font-weight: 600; font-size: 13px; margin-bottom: 8px; line-height: 1.35; }
.card-meta  { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: .03em;
}
.badge-type    { background: #1c2e4a; color: #79b8ff; }
.badge-critical { background: #3b0d0c; color: #ff7b72; }
.badge-high    { background: #3b1a00; color: #ffa657; }
.badge-medium  { background: #2d2200; color: #e3b341; }
.badge-low     { background: #21262d; color: #8b949e; }
.badge-redesign { background: #3b0d0c; color: #ff7b72; }
.card-footer   { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.assignee-chips { display: flex; }
.assignee-chip  {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface); margin-left: -5px; object-fit: cover;
}
.assignee-chips .assignee-chip:first-child { margin-left: 0; }

/* ---- Overlay + Panel ---- */
#overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 200;
}
#panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 680px; max-width: 100%;
  background: var(--surface); z-index: 201; overflow-y: auto;
  box-shadow: -4px 0 20px rgba(0,0,0,.15);
  display: flex; flex-direction: column;
}
.panel-toolbar {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#panel-body { padding: 24px; display: flex; flex-direction: column; gap: 24px; }

/* ---- Panel: header ---- */
.panel-title { font-size: 20px; font-weight: 700; line-height: 1.3; }
.panel-onshape-link { font-size: 13px; color: var(--accent); text-decoration: none; }
.panel-onshape-link:hover { text-decoration: underline; }

/* ---- Panel: meta grid ---- */
.meta-grid {
  display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.meta-label { font-size: 12px; font-weight: 600; color: var(--muted); align-self: center; }
.meta-value { font-size: 13px; align-self: center; }

/* ---- Panel: actions ---- */
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
button.btn {
  padding: 6px 14px; border-radius: var(--radius); font: inherit; cursor: pointer;
  font-size: 13px; border: 1px solid transparent;
}
.btn-primary  { background: var(--accent);  color: #fff; border-color: var(--accent); }
.btn-primary:hover  { background: var(--accent-hov); border-color: var(--accent-hov); }
.btn-danger   { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover   { background: #2d1214; }
.btn-default  { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-default:hover  { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---- Panel: section headings ---- */
.section-heading {
  font-size: 13px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border); padding-bottom: 6px;
}

/* ---- Markdown output ---- */
.md h1,.md h2,.md h3 { margin: 12px 0 6px; font-size: 15px; }
.md p  { margin: 6px 0; line-height: 1.6; }
.md ul,.md ol { margin: 6px 0 6px 20px; line-height: 1.6; }
.md code { background: var(--bg); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.md pre  { background: var(--bg); padding: 12px; border-radius: var(--radius); overflow-x: auto; margin: 8px 0; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--border); padding-left: 12px; color: var(--muted); margin: 8px 0; }
.md table { border-collapse: collapse; margin: 8px 0; }
.md th,.md td { border: 1px solid var(--border); padding: 6px 10px; }
.md th { background: var(--bg); }
.md a  { color: var(--accent); }
.md input[type=checkbox] { margin-right: 4px; }

/* ---- Comments ---- */
.comment { border-top: 1px solid var(--border); padding-top: 14px; }
.comment-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.comment-meta strong { color: var(--text); }

/* ---- Add comment ---- */
.add-comment textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font: inherit; font-size: 13px;
  resize: vertical; min-height: 80px;
  background: var(--bg); color: var(--text);
}
.add-comment textarea:focus { outline: none; border-color: var(--accent); }
.add-comment-footer { display: flex; justify-content: flex-end; margin-top: 8px; }

/* ---- History entries ---- */
.history-entry {
  border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px;
  font-size: 12px; color: var(--muted); line-height: 1.5;
}
.hist-actor { color: var(--text); font-weight: 600; }
.hist-from  { color: var(--muted); text-decoration: line-through; font-size: 12px; }
.hist-to    { color: var(--text); font-size: 12px; }
.hist-time  { float: right; }

/* ---- Admin edit controls ---- */
.admin-select {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: 13px; padding: 3px 6px; cursor: pointer;
}
.admin-select:focus { outline: none; border-color: var(--accent); }
.admin-input {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: 13px; padding: 3px 6px; width: 100%;
}
.admin-input:focus { outline: none; border-color: var(--accent); }
.admin-title-input {
  width: 100%; font-size: 20px; font-weight: 700; background: transparent;
  border: none; border-bottom: 1px solid var(--border); color: var(--text);
  padding: 2px 0; margin-bottom: 4px; font-family: inherit;
}
.admin-title-input:focus { outline: none; border-bottom-color: var(--accent); }
.admin-textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font: inherit; font-size: 13px;
  resize: vertical; min-height: 120px;
  background: var(--bg); color: var(--text);
}
.admin-textarea:focus { outline: none; border-color: var(--accent); }

/* ---- Card submitter ---- */
.card-submitter { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---- Multi-select ---- */
.ms-wrap { position: relative; }
.ms-trigger {
  width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px 8px; font: inherit; font-size: 13px;
  cursor: pointer; color: var(--text);
}
.ms-trigger:hover { border-color: var(--muted); }
.ms-dropdown {
  position: absolute; z-index: 300; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 220px; display: flex; flex-direction: column;
}
.ms-search {
  padding: 6px 10px; border: none; border-bottom: 1px solid var(--border);
  font: inherit; font-size: 13px; outline: none; flex-shrink: 0;
  background: var(--surface); color: var(--text);
}
.ms-list { overflow-y: auto; flex: 1; }
.ms-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  cursor: pointer; font-size: 13px;
}
.ms-item:hover { background: var(--bg); }
.ms-check { width: 14px; color: var(--accent); font-weight: 700; visibility: hidden; flex-shrink: 0; }
.ms-selected .ms-check { visibility: visible; }
.ms-avatar {
  width: 24px; height: 24px; border-radius: 50%; object-fit: cover;
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
}
.ms-avatar-initials { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; }
.ms-name { flex: 1; }
.ms-email-hint { font-size: 11px; color: var(--muted); }

/* ---- Files ---- */
.file-row { display: flex; align-items: center; gap: 10px; padding: 6px 0;
            border-top: 1px solid var(--border); }
.file-row:first-child { border-top: none; }
.file-name { font-size: 13px; color: var(--accent); text-decoration: none; flex: 1; }
.file-name:hover { text-decoration: underline; }
.file-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.add-file input[type=file] { font: inherit; font-size: 13px; }

/* ---- Redesign chain ---- */
.redesign-link { font-size: 13px; }
.redesign-link a { color: var(--accent); text-decoration: none; }
.redesign-link a:hover { text-decoration: underline; }

/* ---- Generic button (login) ---- */
button:not(.btn):not(.filter-btn):not(.icon-btn) {
  padding: 8px 20px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
button:not(.btn):not(.filter-btn):not(.icon-btn):hover {
  border-color: var(--accent); color: var(--accent);
}
