:root {
  --bg: #f5f6f8; --card: #fff; --text: #1d2330; --muted: #6b7385; --line: #e2e5ea;
  --accent: #3b5bdb; --danger: #d6336c; --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171d; --card: #1d2129; --text: #e4e7ec; --muted: #8b93a5; --line: #2c313b; --accent: #748ffc; --danger: #f06595; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

.top { display: flex; align-items: center; gap: 1.5rem; padding: .75rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.top nav { display: flex; gap: 1rem; flex: 1; }
.top .me { display: flex; gap: 1rem; }
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 480px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.head h1 { margin: 0 0 .5rem; }

form label { display: block; margin-bottom: .75rem; font-weight: 500; font-size: .9rem; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .btn { display: inline-block; padding: .5rem 1rem; font: inherit; font-weight: 500; color: #fff; background: var(--accent);
  border: 0; border-radius: 6px; cursor: pointer; }
.btn:hover { text-decoration: none; opacity: .9; }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 400; }
button.danger, .danger { color: var(--danger); }
form.inline, td.actions form { display: inline; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters select, .filters input { width: auto; margin: 0; }
.filters input { flex: 1; min-width: 150px; }

table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem; }
.list th, .list td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.list tr:last-child td { border-bottom: 0; }
.list tr.inactive { opacity: .5; }
td.actions { white-space: nowrap; }
td.actions > * + * { margin-left: .75rem; }
td.actions .pw input { display: inline-block; width: 120px; margin: 0; padding: .2rem .4rem; font-size: .85rem; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.status-open        { background: #e7f0ff; color: #1c4fbf; }
.status-in_progress { background: #fff4e0; color: #a5620a; }
.status-resolved    { background: #e3f8e9; color: #1d7a3a; }
.status-closed      { background: #eceef1; color: #5b6272; }
.priority-low       { background: #eceef1; color: #5b6272; }
.priority-normal    { background: #e7f0ff; color: #1c4fbf; }
.priority-high      { background: #fff0e0; color: #b8590b; }
.priority-critical  { background: #ffe3e8; color: #c01c45; }

.flash { padding: .6rem .9rem; border-radius: 6px; margin-bottom: 1rem; background: #e3f8e9; color: #1d7a3a; }
.flash.err { background: #ffe3e8; color: #c01c45; }

.bug-layout { display: grid; grid-template-columns: 1fr 260px; gap: 1.25rem; align-items: start; }
.bug-layout aside { position: sticky; top: 1rem; }
.text { white-space: normal; word-wrap: break-word; }
.comment { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .6rem; }
.comment .meta { display: flex; gap: .75rem; align-items: baseline; margin-bottom: .25rem; font-size: .9rem; }
.comment.system { background: transparent; border-style: dashed; font-size: .88rem; color: var(--muted); }

/* Images */
.gallery, .previews { display: flex; flex-wrap: wrap; gap: .6rem; margin: .75rem 0; }
.previews:empty { display: none; }
.gallery figure, .previews figure { position: relative; margin: 0; }
.gallery img { display: block; max-width: 220px; max-height: 160px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); object-fit: contain; }
.previews img { display: block; width: 90px; height: 70px; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; }
.gallery figure form { position: absolute; top: 4px; right: 4px; }
.del { width: 22px; height: 22px; padding: 0; line-height: 20px; font-size: 16px; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; opacity: 0; transition: opacity .15s; }
.previews .del { position: absolute; top: 3px; right: 3px; opacity: 1; }
.gallery figure:hover .del, .del:focus { opacity: 1; }
.comment .gallery img { max-width: 180px; max-height: 130px; }
details.add-images { margin-top: .75rem; }
details.add-images summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
details.add-images form { margin-top: .75rem; }
form.dragging { outline: 2px dashed var(--accent); outline-offset: 4px; }
@media (hover: none) { .del { opacity: 1; } }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: .75rem; padding: .75rem 1rem; }
  main { padding: 1rem; }
  .bug-layout { grid-template-columns: 1fr; }
  .bug-layout aside { position: static; }
  table.list { display: block; overflow-x: auto; }
}
