:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --ink: #0e2a2b;
  --muted: #4e6566;
  --line: #cfdad6;
  --accent: #0b7a53;
  --accent-ink: #ffffff;
  --fail: #b4321f;
  --warn: #8a5a00;
  --tint: #e6efeb;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1f20;
    --surface: #12292a;
    --ink: #e4efec;
    --muted: #9db3b0;
    --line: #27413f;
    --accent: #3ecf8e;
    --accent-ink: #06231a;
    --fail: #ff8a75;
    --warn: #f0c060;
    --tint: #183635;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 22px; margin: 0; text-wrap: balance; }
h2 { font-size: 16px; margin: 0 0 12px; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.topbar nav a[aria-current="page"] { background: var(--tint); color: var(--ink); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; }

main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; outline: none; }
footer { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }

label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  min-width: 0;
}
textarea { resize: vertical; min-height: 84px; }

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 7px 14px;
}
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.danger { background: transparent; color: var(--fail); border-color: var(--fail); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge[data-status="open"] { color: var(--fail); border-color: currentColor; }
.badge[data-status="in_progress"] { color: var(--warn); border-color: currentColor; }
.badge[data-status="resolved"], .badge[data-status="done"] { color: var(--accent); border-color: currentColor; }
.badge[data-status="closed"] { color: var(--muted); }
.badge[data-priority="critical"] { background: var(--fail); color: var(--surface); border-color: var(--fail); }
.badge[data-priority="high"] { color: var(--fail); border-color: currentColor; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; }

.auth { max-width: 380px; margin: 8vh auto 0; }
.auth h1 { margin-bottom: 4px; }
.auth form { display: grid; gap: 12px; margin-top: 16px; }

.error { color: var(--fail); font-weight: 600; margin: 0; }

.detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 720px) { .detail { grid-template-columns: 1fr; } }
.comment { border-top: 1px solid var(--line); padding: 12px 0; }
.comment p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 20px; width: min(480px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog form { display: grid; gap: 12px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 6px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.2); }
.toast.is-error { background: var(--fail); color: var(--surface); }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; vertical-align: -2px; margin-right: 6px; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
