:root {
  --canvas: #f5f7f2;
  --card: #ffffff;
  --line: #e1e4de;
  --line-soft: #eef0ec;
  --input: #cdd2cb;
  --ink: #1a1d1b;
  --muted: #545c56;
  --accent: #29754f;
  --accent-ink: #ffffff;
  --accent-soft: #e4efe8;
  --accent-deep: #18452f;
  --amber-soft: #fbf0dc;
  --amber-line: #e9cf9e;
  --amber-ink: #5a3a05;
  --red-soft: #fbe6e4;
  --red-ink: #8e2626;
  --violet-soft: #ece8fb;
  --violet-ink: #45318f;
  --blue-soft: #e3eef8;
  --blue-ink: #1b4670;
  --grey-soft: #eef0ec;
  --grey-ink: #3f4741;
  --scrim: rgba(17, 20, 18, 0.55);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #121416;
    --card: #1c1f22;
    --line: #2c3034;
    --line-soft: #25292c;
    --input: #3b4044;
    --ink: #e8ebe7;
    --muted: #a4aca6;
    --accent: #6fbf93;
    --accent-ink: #0f1a14;
    --accent-soft: #1f3328;
    --accent-deep: #bfe3cd;
    --amber-soft: #3a2e17;
    --amber-line: #6b5326;
    --amber-ink: #f3d9a4;
    --red-soft: #3d1f1d;
    --red-ink: #f4b8b2;
    --violet-soft: #2a2542;
    --violet-ink: #cfc5f7;
    --blue-soft: #1d2c3b;
    --blue-ink: #b9d4ef;
    --grey-soft: #2a2e31;
    --grey-ink: #cdd3ce;
    --scrim: rgba(0, 0, 0, 0.65);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.6; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.6px; }
h2 { margin: 0; font-size: 16px; font-weight: 800; }
p { margin: 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.head { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.spread { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }

header.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; }
.brand strong { display: block; font-size: 16px; letter-spacing: -0.3px; }
.grow { flex: 1 1 120px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-deep);
  font-weight: 800; display: grid; place-items: center; flex: none; text-transform: uppercase;
}

.layout {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 24px;
  padding: 24px; max-width: 1480px; margin: 0 auto;
}
nav.side { flex: 1 1 200px; max-width: 240px; display: flex; flex-direction: column; gap: 4px; }
nav.side button {
  display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 0;
  text-align: left; font-weight: 600; background: transparent; color: var(--grey-ink);
}
nav.side button[aria-current='page'] { background: var(--accent-soft); color: var(--accent-deep); font-weight: 800; }
.note { margin-top: 16px; padding: 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.note strong { display: block; color: var(--ink); margin-bottom: 4px; }
main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

@media (max-width: 640px) {
  .layout { padding: 16px; }
  nav.side { max-width: none; flex-direction: row; flex-wrap: wrap; }
  nav.side .note { display: none; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tile .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile .value { font-size: 28px; font-weight: 800; letter-spacing: -0.6px; margin-top: 4px; }
.cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.cols > * { flex: 1 1 360px; min-width: 0; }

.btn {
  min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--input);
  background: var(--card); font-weight: 700;
}
.btn.primary { border: 0; background: var(--accent); color: var(--accent-ink); }
.btn.danger { border-color: #e8b4b0; color: var(--red-ink); }
.btn.big { min-height: 44px; padding: 0 16px; border-radius: 12px; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.input {
  height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--input);
  background: var(--card); font-size: 14px; font-weight: 400; color: var(--ink);
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input.changed { border: 2px solid #d49a2a; background: var(--amber-soft); }
input.limit { width: 100%; max-width: 130px; height: 40px; }

.pill {
  display: inline-flex; align-items: center; flex: none; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--grey-soft); color: var(--grey-ink);
}
.pill.green { background: var(--accent-soft); color: var(--accent-deep); }
.pill.amber { background: var(--amber-soft); color: var(--amber-ink); }
.pill.red { background: var(--red-soft); color: var(--red-ink); }
.pill.violet { background: var(--violet-soft); color: var(--violet-ink); }
.pill.blue { background: var(--blue-soft); color: var(--blue-ink); }

.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 16px;
  border: 0; border-bottom: 1px solid var(--line-soft); background: var(--card); text-align: left;
}
.list-row[aria-pressed='true'] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.list-row .who { flex: 1 1 auto; min-width: 0; }
.list-row .who strong, .list-row .who span { display: block; overflow-wrap: anywhere; }
.line { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.line:last-child { border-bottom: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th { text-align: left; font-size: 12px; color: var(--muted); padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); }
td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
td .was { display: block; font-size: 11px; font-weight: 700; color: var(--amber-ink); margin-top: 2px; }
.nolimit { font-weight: 700; color: var(--violet-ink); }

.segmented { display: inline-flex; flex-wrap: wrap; padding: 3px; border-radius: 12px; background: var(--grey-soft); gap: 2px; }
.segmented button {
  min-height: 38px; padding: 0 14px; border: 0; border-radius: 9px; font-size: 13px; font-weight: 700;
  background: transparent; color: var(--muted);
}
.segmented button[aria-pressed='true'] { background: var(--card); color: var(--accent-deep); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }

.box { padding: 10px 12px; border-radius: 12px; font-size: 13px; background: var(--canvas); color: var(--grey-ink); }
.box.violet { background: var(--violet-soft); color: var(--violet-ink); }
.box.amber { background: var(--amber-soft); color: var(--amber-ink); }
.box.red { background: var(--red-soft); color: var(--red-ink); }

.bar { height: 8px; border-radius: 999px; background: var(--line-soft); margin-top: 5px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 999px; background: var(--accent); }
.bar > div.full { background: #b7791f; }
.bar > div.none { background: #b9aee8; }

.draft-bar {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 12px 16px; border-radius: 16px;
  background: var(--amber-soft); border: 1px solid var(--amber-line); color: var(--amber-ink);
}
.draft-bar .btn { background: transparent; border-color: var(--amber-line); color: var(--amber-ink); }
.draft-bar .btn.primary { background: var(--accent); color: var(--accent-ink); border: 0; }

.scrim { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.dialog {
  width: 100%; max-width: 620px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--card);
  border-radius: 20px; padding: 22px; display: flex; flex-direction: column; gap: 14px;
}
.dialog h2 { font-size: 20px; }
.change { padding: 12px; border-radius: 12px; background: var(--canvas); display: flex; flex-direction: column; gap: 4px; }
.change .warn { font-size: 12px; font-weight: 700; color: var(--amber-ink); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }

.signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.signin .card { max-width: 420px; width: 100%; display: flex; flex-direction: column; gap: 16px; padding: 28px; }
.error { color: var(--red-ink); font-weight: 600; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--canvas);
  padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 20; max-width: calc(100vw - 32px);
}
.empty { padding: 24px; color: var(--muted); text-align: center; }
