:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --ink: #1b1f1c;
  --muted: #5f6b63;
  --line: #dfe4df;
  --brand: #14532d;
  --brand-ink: #ffffff;
  --urgent: #b42318;
  --urgent-bg: #fdecea;
  --high: #b54708;
  --high-bg: #fff4e5;
  --low: #667085;
  --focus: #2e7d32;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111412; --card: #1a1f1c; --ink: #e8ece9; --muted: #9aa69e; --line: #2c342f;
    --brand: #3fa66a; --brand-ink: #08130c; --urgent: #ff8a7a; --urgent-bg: #3a1a16;
    --high: #f5b26b; --high-bg: #33240f; --low: #98a2b3;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: inherit; }
main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 64px; }
h1 { font-size: 22px; margin: 4px 0 6px; }
h2 { font-size: 15px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
pre { white-space: pre-wrap; word-wrap: break-word; font: inherit; margin: 0; }

.top { display: flex; align-items: center; gap: 20px; padding: 10px 16px; background: var(--brand); color: var(--brand-ink); flex-wrap: wrap; }
.top a { text-decoration: none; }
.brand { font-weight: 700; font-size: 17px; }
.top nav { display: flex; gap: 16px; flex: 1; }
.me { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.me form { margin: 0; }

button, .button {
  font: inherit; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .button:hover { border-color: var(--muted); }
button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button.primary, .button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button[disabled] { opacity: .5; cursor: not-allowed; }
button.small { padding: 4px 10px; font-size: 13px; }
button.link { background: none; border: none; color: inherit; text-decoration: underline; padding: 0; }
select, input, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }
textarea { width: 100%; resize: vertical; }
label { display: block; margin-bottom: 8px; }
label input { display: block; width: 100%; margin-top: 4px; }

.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 12px 0 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.count { color: var(--muted); font-weight: 400; }

.tasks { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.task { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.task.is-urgent { border-left: 4px solid var(--urgent); }
.task-main { min-width: 0; flex: 1; }
.task-title { font-weight: 600; text-decoration: none; display: block; margin: 2px 0; }
.task-title:hover { text-decoration: underline; }
.task-detail { margin: 2px 0 0; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task-meta { display: flex; gap: 8px; align-items: center; font-size: 13px; flex-wrap: wrap; }
.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 13px; flex-shrink: 0; }
.task-side form { margin: 0; }
.type { color: var(--muted); }

.prio { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.prio.p1 { background: var(--urgent-bg); color: var(--urgent); }
.prio.p2 { background: var(--high-bg); color: var(--high); }
.prio.p3 { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.prio.p4 { color: var(--low); border: 1px dashed var(--line); }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.pill.urgent { background: var(--urgent); color: #fff; }
.pill.away { background: var(--high-bg); color: var(--high); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.actions form, form.inline { display: flex; gap: 6px; margin: 0; }
.back { display: inline-block; margin-bottom: 10px; color: var(--muted); text-decoration: none; }
.detail { background: var(--bg); padding: 10px; border-radius: 8px; margin: 8px 0; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.flash { background: var(--high-bg); padding: 8px 12px; border-radius: 8px; }
.error { color: var(--urgent); }
.notice { background: var(--bg); padding: 10px; border-radius: 8px; }

.ticket-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.thread { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.msg { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.msg.out { background: transparent; border-style: dashed; }
.msg-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 14px; }
.notes { background: var(--high-bg); padding: 10px; border-radius: 8px; margin-bottom: 10px; font-size: 14px; }
.reply textarea { margin-top: 4px; }

.activity ul, .plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; }
.activity { margin-top: 12px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; background: var(--line); }
.dot.ok { background: var(--brand); }

.login { max-width: 380px; margin: 12vh auto; text-align: center; }
.login .dev { margin-top: 28px; text-align: left; }

@media (max-width: 760px) {
  .ticket-grid { grid-template-columns: 1fr; }
  .task { flex-direction: column; }
  .task-side { flex-direction: row; align-items: center; align-self: stretch; justify-content: space-between; }
  .top nav { order: 3; width: 100%; }
}

.bulk { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; }
.inline-check { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.pick { margin-top: 4px; width: 18px; height: 18px; flex-shrink: 0; }
.principle input[name=title] { width: 100%; font-weight: 600; margin-bottom: 8px; }
.principle.inactive { opacity: .6; }
.card > input, .card > textarea { width: 100%; margin-bottom: 8px; }
.pill.private { background: var(--bg); color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.inline-check { white-space: nowrap; } .inline-check input { display: inline-block; width: auto; margin: 0; }
