:root {
  --bg: #f5f6f8; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e5e7eb;
  --primary: #2453d6; --primary-dark: #1b3fa6; --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(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }

.topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
          gap: 1rem; padding: .75rem 1.5rem; background: #111827; }
.topbar a, .topbar .link { color: #e5e7eb; }
.topbar nav { display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: #fff !important; }
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 1.25rem; margin-bottom: 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.narrow { max-width: 460px; margin: 2rem auto; }
.narrow.wide { max-width: 720px; }
.grid { display: grid; gap: 1.25rem; }
.grid.two { grid-template-columns: 2fr 1fr; }
.grid.two-1 { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
@media (max-width: 860px) { .grid.two, .grid.two-1 { grid-template-columns: 1fr; } }

.btn { display: inline-block; background: var(--primary); color: #fff !important; border: 0;
       border-radius: 8px; padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-small { padding: .3rem .7rem; font-size: .85rem; }
.btn-ghost { background: transparent; color: var(--primary) !important; border: 1px solid var(--primary); }
.btn-ghost:hover { background: #eef2ff; }
button.link { background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }
form.inline { display: inline; }
.actions { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; }

form div { margin-bottom: .9rem; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=file], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid #cfd4dc; border-radius: 8px; font: inherit; background: #fff; }
input[type=checkbox] { margin-right: .4rem; }
.helptext, form div > span { display: block; color: var(--muted); font-size: .8rem; font-weight: 400; }
.errorlist { color: #b42318; margin: .25rem 0; padding-left: 1rem; font-size: .85rem; }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.filters label { flex: 1 1 160px; margin: 0; }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem;
            text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--line); padding: .5rem; }
.table td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: #fafbfc; }
.card:has(.table) { overflow-x: auto; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem;
         font-weight: 600; font-style: normal; background: #eef0f3; color: #374151; }
.status-open { background: #e0e7ff; color: #3730a3; }
.status-in_progress { background: #fef3c7; color: #92400e; }
.status-on_hold { background: #f3e8ff; color: #6b21a8; }
.status-resolved { background: #dcfce7; color: #166534; }
.status-closed { background: #e5e7eb; color: #374151; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.priority-low { background: #f1f5f9; color: #475569; }
.priority-medium { background: #e0f2fe; color: #075985; }
.priority-high { background: #ffedd5; color: #9a3412; }
.priority-urgent { background: #dc2626; color: #fff; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 1rem; color: var(--muted) !important; font-size: .88rem; }
.stat span { display: block; font-size: 1.8rem; font-weight: 700; color: var(--text); }
.stats.small .stat span { font-size: 1.3rem; }
a.stat:hover { border-color: var(--primary); text-decoration: none; }
.stat.accent { border-left: 4px solid var(--primary); }
.stat.danger { border-left: 4px solid #dc2626; }
.stat.warn { border-left: 4px solid #f59e0b; }

.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: flex; justify-content: space-between; padding: .45rem 0; border-bottom: 1px solid var(--line); }

.meta { display: flex; gap: .4rem; flex-wrap: wrap; }
.description { margin: 1rem 0; }
.comment { border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem; margin-bottom: .75rem; }
.comment.staff { background: #f8faff; }
.comment.internal { background: #fffbeb; border-color: #fde68a; }
.comment-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.comment p { margin: .4rem 0 0; }
.reply { margin-top: 1rem; }

.details { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0; font-size: .92rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 .9rem .9rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px;
                       border-radius: 50%; background: var(--primary); }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: #eef2ff; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #e0f2fe; color: #075985; }
.pager { display: flex; justify-content: space-between; align-items: center; padding-top: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
