:root {
  --bg: #f5f7fb;
  --card: #fff;
  --text: #1f2933;
  --muted: #6b7785;
  --border: #e3e8ef;
  --brand: #1a73e8;
  --brand-dark: #1557b0;
  --danger: #c5221f;
  --radius: 10px;
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 .6rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }

.topbar { background: #fff; border-bottom: 1px solid var(--border); margin-bottom: 1.75rem; }
.topbar .wrap { display: flex; align-items: center; gap: 1.5rem; min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.links { display: flex; gap: 1.1rem; flex: 1; flex-wrap: wrap; }
.links a { color: var(--muted); padding: .3rem 0; border-bottom: 2px solid transparent; }
.links a.active, .links a:hover { color: var(--text); border-bottom-color: var(--brand); text-decoration: none; }
.user { display: flex; align-items: center; gap: .75rem; }
.who { color: var(--muted); font-size: .9rem; }
.footer { color: var(--muted); font-size: .8rem; padding: 2rem 1.25rem; text-align: center; }

.btn { display: inline-block; background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 6px; padding: .5rem 1rem;
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: #f0f3f8; }
.btn.danger { background: #fff; color: var(--danger); border-color: #f1c4c3; }
.btn.small { padding: .25rem .65rem; font-size: .85rem; }
.btn.large { padding: .75rem 1.6rem; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }
.inline-top { margin-top: .6rem; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.card.center { text-align: center; max-width: 560px; margin: 2rem auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.crumbs { color: var(--muted); font-size: .9rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem 0; margin: 0; }
.ok { color: #188038; } .bad { color: var(--danger); }

.hero { text-align: center; padding: 2.5rem 1rem 2rem; }
.hero h1 { font-size: 2.2rem; }
.hero p { max-width: 560px; margin: 0 auto 1.25rem; color: var(--muted); }
.grid { display: grid; gap: 1.25rem; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.detail { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
.card.dev { max-width: 420px; margin: 1rem auto; border-style: dashed; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; color: var(--text); border-top: 4px solid var(--border); }
.stat:hover { text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.stat .n { display: block; font-size: 1.8rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .9rem; }
.stat.open { border-top-color: #1a73e8; } .stat.in_progress { border-top-color: #f29900; }
.stat.resolved { border-top-color: #188038; } .stat.closed { border-top-color: #9aa0a6; }
.stat.warn { border-top-color: #d93025; } .stat.mine { border-top-color: #8430ce; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .85rem; }
tbody tr:last-child td { border-bottom: 0; }
td.num { color: var(--muted); width: 3rem; }
table.kv th { width: 30%; color: var(--text); background: #fafbfd; }
table.kv td { word-break: break-all; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eef1f5; color: #3c4652; white-space: nowrap; }
.status-open { background: #e8f0fe; color: #1a5fc6; }
.status-in_progress { background: #fef3e0; color: #a35d00; }
.status-resolved { background: #e6f4ea; color: #137333; }
.status-closed { background: #eef1f5; color: #5f6873; }
.priority-low { background: #eef1f5; color: #5f6873; }
.priority-normal { background: #e8f0fe; color: #1a5fc6; }
.priority-high { background: #fef3e0; color: #a35d00; }
.priority-urgent { background: #fce8e6; color: #b3261e; }
.badge.role { background: #f3e8fd; color: #7627bb; }
.badge.note { background: #fff4ce; color: #7a5b00; }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1.25rem; border: 1px solid; }
.flash.success { background: #e6f4ea; border-color: #b7dfc2; color: #0d652d; }
.flash.error { background: #fce8e6; border-color: #f5c2bd; color: #a50e0e; }
.flash.warn { background: #fef7e0; border-color: #f6dfa1; color: #7a5b00; }

label { display: block; font-weight: 500; font-size: .92rem; }
input[type=text], input[type=email], input[type=search], select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c6dafc; border-color: var(--brand); }
.stack > * + * { margin-top: .9rem; }
.form { max-width: 760px; }
.actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.actions .check { margin-right: auto; }
label.check { display: flex; gap: .4rem; align-items: center; font-weight: 400; }
label.check input { margin: 0; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; margin: 0; }
.filters input[type=search] { flex: 1; min-width: 200px; }

.prose { white-space: pre-wrap; word-wrap: break-word; }
.meta { margin-bottom: .4rem; }
.timeline { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.timeline li { padding: .8rem 0; border-bottom: 1px solid var(--border); }
.timeline li.note { background: #fffbea; margin: 0 -1.25rem; padding: .8rem 1.25rem; }
.timeline li.event { color: var(--muted); font-size: .88rem; padding: .45rem 0; }
.facts dl { margin: 0; display: grid; grid-template-columns: 90px 1fr; gap: .45rem .75rem; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; }

.kb-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.kb-item { color: var(--text); margin: 0; }
.kb-item:hover { text-decoration: none; border-color: #c6dafc; }
pre { background: #f5f7fb; padding: 1rem; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; font-size: .78rem; }

@media (max-width: 800px) {
  .grid.two, .grid.three, .grid.detail { grid-template-columns: 1fr; }
}
