:root {
  --blue-dark: #1e3a5f; --blue: #2c5a8e; --blue-med: #4a7ba7; --blue-light: #d4e7f0; --blue-hero: #4A90E2;
  --orange: #eb9735; --orange-dark: #d4851e; --orange-light: #fef3e0;
  --green: #4CAF50; --green-dark: #388E3C; --green-light: #e8f5e9;
  --red: #d64545; --red-light: #fdecec; --gold: #f8db09;
  --ink: #1f2933; --muted: #6b7785; --line: #e3e8ee; --bg: #f4f6f9; --card: #fff;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 12px -4px rgba(0,0,0,.08);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; color: var(--blue-dark); }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; color: var(--blue-dark); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

header.top { background: #fff; border-bottom: 1px solid var(--line); padding: .5rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--blue-dark); font-size: 1.05rem; }
.brand img { height: 34px; width: auto; }
.brand span { border-left: 2px solid var(--line); padding-left: .6rem; color: var(--orange-dark); }
header nav { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.navlink { color: var(--blue-dark); font-weight: 500; }
.who { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff; font-size: .75rem; font-weight: 700; letter-spacing: .02em; flex: none; }
.avatar.sm { width: 22px; height: 22px; font-size: .6rem; margin-right: .3rem; }
form.inline { display: inline; }
.linklike { background: none; border: 0; color: var(--blue); cursor: pointer; font: inherit; padding: 0; }
.linklike:hover { text-decoration: underline; }

main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
main.wide { max-width: 1200px; }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; border-top: 1px solid var(--line); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1rem; }
.auth { max-width: 440px; margin: 2rem auto; }
.form-card { max-width: 820px; margin: 0 auto; }

label { display: block; font-weight: 600; font-size: .85rem; color: var(--blue-dark); margin-bottom: .8rem; }
label .muted { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], input:not([type]), select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; font: inherit; color: var(--ink);
  border: 1px solid #cdd5df; border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-hero); outline-offset: 0; border-color: var(--blue-hero); }
textarea { resize: vertical; min-height: 5rem; }
input[type=file] { margin-top: .35rem; font-size: .9rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.actions { display: flex; gap: .6rem; align-items: center; margin-top: .5rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; padding: .5rem .95rem; border-radius: 8px; border: 1px solid #cdd5df; background: #fff; color: var(--blue-dark); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--orange); border-color: var(--orange-dark); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.block { width: 100%; margin-bottom: .5rem; }
.error { background: var(--red-light); color: #8b1e1e; border: 1px solid #f3c2c2; padding: .6rem .8rem; border-radius: 8px; margin-bottom: .8rem; }
.flash { max-width: 1200px; margin: .75rem auto 0; padding: .55rem 1rem; border-radius: 8px; background: var(--green-light); color: var(--green-dark); border: 1px solid #bfe3c2; }
.flash.err { background: var(--red-light); color: #8b1e1e; border-color: #f3c2c2; }

/* list */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.count { display: inline-block; background: var(--blue-light); color: var(--blue-dark); font-size: .75rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; vertical-align: middle; }
.stats { display: flex; gap: .4rem; flex-wrap: wrap; }
.stat { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .5rem; border-radius: 8px; border: 1px solid transparent; }
.stat b { font-size: .85rem; }
.stat:hover, .stat.on { border-color: var(--line); background: #fff; text-decoration: none; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .9rem; }
.filters input, .filters select { margin: 0; width: auto; }
.filters input[type=search] { flex: 1 1 220px; }
.filters .chk { display: inline-flex; align-items: center; gap: .35rem; margin: 0; font-weight: 500; }
.filters .chk input { width: auto; margin: 0; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.tickets { width: 100%; border-collapse: collapse; min-width: 860px; }
table.tickets th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .65rem .75rem; border-bottom: 1px solid var(--line); }
table.tickets td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tickets tr.row { cursor: pointer; }
table.tickets tr.row:hover { background: #fbfcfe; }
table.tickets tr:last-child td { border-bottom: 0; }
td.key { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; white-space: nowrap; color: var(--muted); }
td.title a { color: var(--ink); font-weight: 600; }
td.title .sub { margin-top: .25rem; display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; font-size: .78rem; }
.area { color: var(--muted); }
.clip { color: var(--muted); }
.jira { font-size: .75rem; color: var(--muted); font-family: ui-monospace, monospace; margin-top: .2rem; }
.who-cell { white-space: nowrap; font-size: .9rem; }
tr.st-closed td.title a, tr.st-resolved td.title a { color: var(--muted); font-weight: 500; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* badges */
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; white-space: nowrap; letter-spacing: .01em; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.sev-blocker { background: var(--red); color: #fff; border-color: var(--red); }
.sev-major { background: var(--orange-light); color: var(--orange-dark); border-color: #f3d3a5; }
.sev-minor { background: var(--blue-light); color: var(--blue-dark); border-color: #b9d3e2; }
.sev-trivial { background: var(--bg); color: var(--muted); }
.status-open { background: var(--blue); color: #fff; border-color: var(--blue); }
.status-needs-info { background: #fff6d6; color: #7a5a00; border-color: #f0dd96; }
.status-in-progress { background: var(--orange); color: #fff; border-color: var(--orange-dark); }
.status-resolved { background: var(--green-light); color: var(--green-dark); border-color: #bfe3c2; }
.status-closed { background: #e9ecf0; color: var(--muted); }
.decision-undecided { background: var(--bg); color: var(--muted); }
.decision-send-to-jira { background: #e8e6ff; color: #3f35a8; border-color: #cbc6f5; }
.decision-we-ll-fix { background: var(--green-light); color: var(--green-dark); border-color: #bfe3c2; }
.decision-won-t-fix, .decision-not-a-bug { background: #e9ecf0; color: var(--muted); text-decoration: line-through; }
.cat { background: #fff; }

/* ticket */
.ticket-head { margin-bottom: 1rem; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.crumbs .key { font-family: ui-monospace, monospace; color: var(--blue-dark); font-weight: 700; }
.ticket-title { font-size: 1.45rem; margin: 0; cursor: text; border-radius: 6px; padding: .1rem .3rem; margin-left: -.3rem; }
.ticket-title:hover { background: #fff; outline: 1px dashed #cdd5df; }
.title-form input { font-size: 1.3rem; font-weight: 700; color: var(--blue-dark); margin: 0; }
.meta { font-size: .85rem; margin-top: .25rem; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.rich p { margin: 0 0 .7rem; white-space: normal; overflow-wrap: anywhere; }
.rich p:last-child { margin-bottom: 0; }
.atts { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .9rem; }
.att { margin: 0; max-width: 100%; }
.att img { max-height: 260px; max-width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; }
.att video { max-height: 320px; max-width: 100%; width: 420px; border-radius: 8px; background: #000; display: block; }
.att .file { font-size: 2.2rem; display: block; }
.att figcaption { font-size: .78rem; margin-top: .25rem; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0 0 1rem; padding: 0; }
.timeline .event { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); padding: .35rem 0 .35rem .3rem; border-left: 2px solid var(--line); margin-left: 14px; }
.timeline .comment { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .95rem; margin: .5rem 0; background: #fbfcfe; }
.timeline .comment:target { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-light); }
.comment-head { display: flex; align-items: center; gap: .5rem; font-size: .9rem; margin-bottom: .4rem; }
.comment-form textarea { margin-top: 0; }
.comment-actions { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; flex-wrap: wrap; }
.comment-actions .btn { margin-left: auto; }
.filebtn { display: inline-flex; align-items: center; padding: .4rem .7rem; border: 1px dashed #cdd5df; border-radius: 8px; cursor: pointer; margin: 0; font-weight: 600; font-size: .85rem; }
.filebtn input { display: none; }
.filenames { font-size: .8rem; flex: 1 1 120px; overflow-wrap: anywhere; }
.upload-progress { position: relative; height: 8px; background: var(--line); border-radius: 999px; margin-top: .6rem; overflow: visible; }
.upload-progress .bar { height: 100%; width: 0; background: var(--orange); border-radius: 999px; transition: width .2s; }
.upload-progress .pct { position: absolute; right: 0; top: 10px; font-size: .75rem; color: var(--muted); }
.fields label { margin-bottom: .6rem; }
.fields select, .fields input { padding: .4rem .55rem; }
.kv { font-size: .8rem; margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.kv div { display: flex; justify-content: space-between; gap: .5rem; padding: .15rem 0; }
.kv b { font-weight: 500; color: var(--ink); text-align: right; }
.side-actions .btn { margin-bottom: .45rem; }
.side-actions .btn:last-child { margin-bottom: 0; }

@media (max-width: 860px) {
  .ticket-layout { grid-template-columns: 1fr; }
  .ticket-side { order: -1; }
  .grid3 { grid-template-columns: 1fr; }
  header.top { padding: .5rem .75rem; }
  .brand img { height: 28px; }
  .who { display: none; }
}

/* settings / docs */
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; background: var(--bg); padding: .1em .35em; border-radius: 4px; }
code.token { display: block; padding: .5rem .7rem; font-size: 1rem; background: #fff; border: 1px solid #bfe3c2; margin-top: .4rem; overflow-wrap: anywhere; user-select: all; }
table.tokens { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tokens th, table.tokens td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tokens th { font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.docs pre { background: #1e2a38; color: #e6edf3; padding: .9rem 1rem; border-radius: 8px; overflow-x: auto; font-size: .8rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.docs h2 { margin-top: 1.4rem; }

.setup ol.steps { padding-left: 1.4rem; }
.setup ol.steps > li { margin-bottom: 1.4rem; padding-left: .4rem; }
.setup ol.steps > li::marker { font-weight: 700; color: var(--orange-dark); font-size: 1.1rem; }
.setup ol.steps h2 { margin: 0 0 .3rem; }
.setup ul { padding-left: 1.2rem; }
