:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #66736b;
  --line: #dce4de;
  --paper: #ffffff;
  --control: #ffffff;
  --wash: #f2f6f3;
  --green: #176b48;
  --green-dark: #0c4c31;
  --red: #a83b32;
  --primary: #176b48;
  --primary-hover: #0c4c31;
  --danger: #a83b32;
  --page-glow: rgba(80, 154, 114, .16);
  --card-shadow: rgba(38, 63, 49, .12);
  --list-shadow: rgba(31, 55, 40, .04);
  --list-shadow-hover: rgba(31, 55, 40, .08);
  --hover-line: #b9c9be;
  --focus-ring: rgba(23, 107, 72, .2);
  --count-bg: #e4ebe6;
  --assignee-bg: #e9f3ed;
  --status-bg: #edf1ee;
  --resolved-bg: #e3f3ea;
  --rejected-bg: #fae9e7;
  --rejected-ink: #7b2b25;
  --active-bg: #e7f1f8;
  --active-ink: #255d89;
  --dialog-backdrop: rgba(17, 28, 21, .48);
  --dialog-header: rgba(242, 246, 243, .96);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf5ef;
  --muted: #a3b2a8;
  --line: #34473b;
  --paper: #19231d;
  --control: #111914;
  --wash: #101712;
  --green: #74d9a4;
  --green-dark: #b7f0d0;
  --red: #ff9d93;
  --primary: #267751;
  --primary-hover: #319666;
  --danger: #a83b32;
  --page-glow: rgba(52, 143, 94, .18);
  --card-shadow: rgba(0, 0, 0, .34);
  --list-shadow: rgba(0, 0, 0, .16);
  --list-shadow-hover: rgba(0, 0, 0, .28);
  --hover-line: #50685a;
  --focus-ring: rgba(116, 217, 164, .28);
  --count-bg: #29372f;
  --assignee-bg: #20392b;
  --status-bg: #29352d;
  --resolved-bg: #203c2d;
  --rejected-bg: #422724;
  --rejected-ink: #ffc2bc;
  --active-bg: #1d3445;
  --active-ink: #8dc9f0;
  --dialog-backdrop: rgba(3, 8, 5, .72);
  --dialog-header: rgba(16, 23, 18, .96);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, var(--page-glow), transparent 32rem),
    var(--wash);
}

button, input, select, textarea { font: inherit; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 72px 0; }

.theme-toggle {
  position: fixed;
  z-index: 20;
  top: 18px;
  right: max(16px, calc((100vw - 1180px) / 2));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 6px 22px var(--list-shadow);
  cursor: pointer;
  font-weight: 750;
}
.theme-toggle:hover { border-color: var(--hover-line); background: var(--control); }
.theme-toggle:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.theme-toggle-icon { width: 16px; color: var(--green); font-size: 18px; line-height: 1; text-align: center; }

.login-panel {
  width: min(460px, 100%);
  margin: 12vh auto 0;
  padding: 42px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 22px 80px var(--card-shadow);
}

.login-panel p { color: var(--muted); line-height: 1.55; margin: 8px 0 28px; }
.login-panel strong { color: var(--ink); }
.setup-panel { width: min(520px, 100%); margin-top: 6vh; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 22px;
  border-radius: 16px;
  color: white;
  background: var(--primary);
  font-weight: 800;
  letter-spacing: -.04em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; letter-spacing: -.035em; }
.eyebrow { margin-bottom: 4px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

.topbar, .identity, .toolbar, .dialog-actions { display: flex; align-items: center; }
.topbar { justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.identity { gap: 14px; color: var(--muted); }

.account-form { display: grid; gap: 16px; text-align: left; }
.account-form label, dialog label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}
.account-form .button { width: 100%; }
.field-hint, .section-copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.account-form .field-hint { margin: -4px 0 0; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}
.button:disabled { cursor: wait; opacity: .55; }
.primary { color: white; background: var(--primary); }
.primary:hover { background: var(--primary-hover); }
.quiet { color: var(--ink); background: var(--control); border-color: var(--line); }
.quiet:hover { background: var(--wash); }
.danger { color: white; background: var(--danger); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 13px 18px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 750;
}
.tab.active { color: var(--green); border-bottom-color: var(--green); }
.count { display: inline-block; min-width: 25px; margin-left: 6px; padding: 2px 7px; border-radius: 999px; background: var(--count-bg); font-size: 12px; }

.toolbar { justify-content: space-between; gap: 20px; padding: 18px 0; }
.toolbar label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
select, input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: var(--control);
}
select, input { min-height: 40px; padding: 0 11px; }
textarea { padding: 11px; resize: vertical; }

.report-list { display: grid; gap: 14px; }
.report-list-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 17px 19px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: var(--paper);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 5px 18px var(--list-shadow);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.report-list-item:hover {
  border-color: var(--hover-line);
  box-shadow: 0 8px 22px var(--list-shadow-hover);
  transform: translateY(-1px);
}
.report-list-item:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}
.report-list-copy { min-width: 0; }
.report-list-badges { display: flex; flex: none; align-items: center; gap: 8px; }
.assignee {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--green);
  background: var(--assignee-bg);
  font-size: 12px;
  font-weight: 750;
}
.report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.report-title { margin: 0 0 6px; font-size: 17px; }
.report-meta, .report-context { color: var(--muted); font-size: 13px; }
.report-meta-stack { display: grid; gap: 4px; }
.report-detail-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}
.report-section { margin-top: 20px; }
.report-section h3 { margin-bottom: 8px; font-size: 14px; }
.report-description { margin: 18px 0; line-height: 1.58; white-space: pre-wrap; }
.report-title-editor {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 16px 0 4px;
  padding: 13px;
  border-radius: 11px;
  background: var(--wash);
}
.report-title-editor label {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.report-title-editor input { background: var(--paper); }
.details-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 15px 0; }
.detail { padding: 12px; border-radius: 10px; background: var(--wash); }
.detail strong { display: block; margin-bottom: 5px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.detail div { white-space: pre-wrap; }
.report-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.completion-block {
  margin-top: 15px;
  padding: 13px;
  border-radius: 10px;
  color: var(--green-dark);
  background: var(--resolved-bg);
  font-size: 14px;
  font-weight: 650;
}
.completion-block div {
  margin-top: 7px;
  font-weight: 400;
  line-height: 1.5;
  white-space: pre-wrap;
}
.rejected-completion { color: var(--rejected-ink); background: var(--rejected-bg); }

.status {
  flex: none;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--status-bg);
  font-size: 12px;
  font-weight: 800;
}
.status.resolved_manually { color: var(--green); background: var(--resolved-bg); }
.status.rejected { color: var(--red); background: var(--rejected-bg); }
.status.active { color: var(--active-ink); background: var(--active-bg); }

.notice, .empty { padding: 16px; border-radius: 11px; text-align: center; }
.notice { margin-bottom: 14px; color: var(--red); background: var(--rejected-bg); }
.empty { color: var(--muted); border: 1px dashed var(--line); }

.section-card {
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(320px, 1.2fr);
  gap: 30px;
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
}
.section-card h2 { margin-bottom: 7px; }
.section-card .section-copy { margin-bottom: 0; }
.section-card .notice { grid-column: 1 / -1; margin-bottom: 0; }
.inline-account-form { grid-template-columns: 1fr 1fr; align-items: end; }
.inline-account-form .button { grid-column: 1 / -1; }
.user-list { display: grid; gap: 10px; }
.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 21px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
}
.user-card h2 { margin-bottom: 5px; font-size: 17px; }
.user-card p { margin-bottom: 0; color: var(--muted); font-size: 13px; }

dialog { width: min(520px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 16px; color: var(--ink); background: var(--paper); box-shadow: 0 30px 100px rgba(0, 0, 0, .4); }
dialog::backdrop { background: var(--dialog-backdrop); }
dialog > form { display: grid; gap: 16px; padding: 24px; }
.dialog-actions { justify-content: flex-end; gap: 9px; margin-top: 4px; }
.optional { color: var(--muted); font-weight: 500; }

.report-dialog {
  width: min(960px, calc(100% - 28px));
  max-height: min(92vh, 980px);
  overflow: hidden;
}
.report-dialog-shell {
  max-height: min(92vh, 980px);
  overflow-y: auto;
  padding: 0 24px 28px;
  background: var(--wash);
}
.report-dialog-header {
  position: sticky;
  z-index: 3;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin: 0 -24px 20px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--dialog-header);
  backdrop-filter: blur(8px);
}
.report-dialog-header h2 { margin-bottom: 0; }
.report-dialog #reportNotice { margin-bottom: 16px; }

.discussion {
  margin-top: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}
.discussion-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.discussion-heading h3 { margin: 0; }
.comment-list { display: grid; gap: 10px; }
.comment {
  padding: 13px 14px;
  border-radius: 11px;
  background: var(--wash);
}
.comment header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 7px;
}
.comment time { color: var(--muted); font-size: 12px; }
.comment > div { line-height: 1.5; white-space: pre-wrap; }
.discussion-empty {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  text-align: center;
}
.comment-form {
  display: grid;
  gap: 9px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.comment-form label { color: var(--muted); font-size: 14px; font-weight: 650; }
.comment-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

@media (max-width: 720px) {
  .shell { width: min(100% - 20px, 1180px); padding-top: 72px; }
  .topbar { align-items: flex-start; }
  .identity { align-items: flex-end; flex-direction: column; }
  .details-grid { grid-template-columns: 1fr; }
  .report-head { flex-direction: column; gap: 10px; }
  .report-list-item { align-items: flex-start; flex-direction: column; gap: 12px; }
  .report-list-badges { flex-wrap: wrap; }
  .report-title-editor { align-items: stretch; flex-direction: column; }
  .report-dialog-shell { padding: 0 14px 20px; }
  .report-dialog-header { margin: 0 -14px 16px; padding: 17px 14px 14px; }
  .report-detail-card, .discussion { padding: 16px; }
  .comment header, .comment-actions { align-items: flex-start; flex-direction: column; }
  .section-card { grid-template-columns: 1fr; gap: 20px; }
  .section-card .notice { grid-column: auto; }
  .inline-account-form { grid-template-columns: 1fr; }
  .inline-account-form .button { grid-column: auto; }
  .user-card { align-items: stretch; flex-direction: column; }
}
