:root {
  color-scheme: light;
  --ink: #202829;
  --muted: #526264;
  --paper: #f1f4f2;
  --stroke: #d7e0da;
  --green: #205e48;
  --accent: #d6efdf;
  --night: #172826;
  --danger: #9b342b;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, input, select, textarea { border: 1px solid var(--stroke); border-radius: 7px; }
button { min-height: 38px; padding: .45rem .85rem; background: white; color: var(--ink); cursor: pointer; }
button:hover { border-color: var(--green); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid #3f9a77; outline-offset: 2px;
}
a { color: var(--green); text-underline-offset: 3px; }
.primary { background: var(--green); border-color: var(--green); color: white; font-weight: 600; }
.primary:hover { background: #184c3a; }
.quiet { background: transparent; border-color: transparent; }
.danger, .error { color: var(--danger); }
.error:empty { display: none; }
.muted, small { color: var(--muted); }
small { font-size: .83rem; }
.layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { background: var(--night); color: white; display: flex; flex-direction: column; padding: 1.6rem 1rem 1rem; gap: 2rem; }
.brand { display: flex; gap: .7rem; align-items: center; font-size: 1.16rem; font-weight: 700; letter-spacing: .04em; }
.brand small { display: block; letter-spacing: 0; font-weight: 400; margin-top: .15rem; }
.mark { padding: .6rem .55rem; border-radius: 9px; background: var(--accent); color: #173b2d; line-height: 1; }
.sidebar .brand { padding: 0 .7rem; }
.sidebar small { color: #b0c8c0; }
.sidebar nav { display: grid; gap: .22rem; align-content: start; }
.sidebar nav button { display: flex; align-items: center; justify-content: space-between; text-align: left; color: #e2ebe6; border-color: transparent; background: transparent; font-size: .93rem; }
.sidebar nav button:hover { background: #263e39; }
.sidebar nav button[aria-current="page"] { color: #fff; background: #315448; }
.sidebar footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding-left: .5rem; }
.sidebar footer button { color: white; }
.count { padding: .1rem .45rem; border-radius: .35rem; background: #d6efdf; color: #173b2d; font-size: .78rem; font-weight: 650; }
.bar { display: flex; gap: 1rem; align-items: center; min-height: 64px; padding: .5rem clamp(1rem, 4vw, 3rem); border-bottom: 1px solid var(--stroke); background: #f9fbfa; font-size: .9rem; }
.bar span:first-child { margin-right: auto; font-weight: 650; }
#mode { color: var(--muted); text-align: right; }
.workspace { max-width: 1440px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 3rem); }
h1 { margin: 0 0 1.4rem; font-size: clamp(1.65rem, 3vw, 2.4rem); letter-spacing: -.04em; }
h2 { font-size: 1.25rem; margin: 0 0 1rem; }
p { white-space: pre-wrap; overflow-wrap: anywhere; }
.toolbar, .buttons { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.toolbar { margin: 0 0 1rem; }
.toolbar form { display: flex; flex-wrap: wrap; flex: 1; gap: .5rem; }
.toolbar input { max-width: 25rem; min-width: 9rem; flex: 1; }
input, select, textarea { width: 100%; background: #fff; color: var(--ink); padding: .56rem .7rem; }
.toolbar select { width: auto; max-width: 100%; }
label { display: grid; gap: .28rem; font-size: .92rem; }
.panel { background: white; border: 1px solid var(--stroke); border-radius: .75rem; padding: 1rem; }
.table-wrap { background: white; border: 1px solid var(--stroke); border-radius: .75rem; overflow: auto; }
table { border-collapse: collapse; text-align: left; width: 100%; font-size: .94rem; }
th, td { padding: .78rem .9rem; border-bottom: 1px solid var(--stroke); vertical-align: top; }
th { background: #f9fbfa; color: var(--muted); font-size: .84rem; font-weight: 650; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td { overflow-wrap: anywhere; }
td:last-child .buttons { min-width: max-content; }
td small { display: block; margin-top: .25rem; }
.pill { display: inline-block; padding: .22rem .55rem; background: #edf0ee; border-radius: 7px; font-size: .83rem; white-space: nowrap; }
.pill.open, .pill.active, .pill.approved, .pill.sent { background: #e5f3eb; color: #21523c; }
.pill.pending, .pill.approval, .pill.applying { background: #fff0d5; color: #744c15; }
.pill.failed { background: #fae9e6; color: var(--danger); }
.caseid { font: 650 .95rem "IBM Plex Mono", Consolas, monospace; color: var(--green); }
.pagination { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .75rem; }
.empty { color: var(--muted); margin: 0; padding: 1.5rem; }
.notice { margin-bottom: 1rem; background: #fff0d5; color: #674212; border: 1px solid #ead4a9; padding: .65rem .85rem; border-radius: 7px; }
.detail { display: grid; grid-template-columns: minmax(14rem, 1fr) minmax(0, 2fr); gap: 1rem; margin-top: 1rem; align-items: start; }
dl { margin: 0 0 1rem; }
dl div { display: flex; align-items: baseline; justify-content: space-between; gap: .9rem; padding: .49rem 0; border-bottom: 1px solid var(--stroke); }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; }
.thread { display: grid; gap: .65rem; margin-bottom: 1rem; }
.message { border: 1px solid var(--stroke); border-radius: .65rem; padding: .65rem; width: fit-content; max-width: 96%; }
.message.out { background: #edf6ef; justify-self: end; }
.message p { margin: .35rem 0; }
.message .meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
#reply { display: grid; gap: .65rem; }
#reply button { justify-self: end; }
.login { width: min(420px, calc(100% - 2rem)); margin: 9vh auto; padding: 1.65rem; border: 1px solid var(--stroke); border-radius: .85rem; background: #fff; }
.login .brand { margin-bottom: 2rem; }
.login form, #dialog-fields { display: grid; gap: 1rem; }
dialog { width: min(480px, calc(100% - 2rem)); border: 1px solid var(--stroke); border-radius: .75rem; padding: 1.25rem; color: var(--ink); }
dialog::backdrop { background: rgb(23 40 38 / 55%); }
dialog .buttons { justify-content: flex-end; margin-top: 1.2rem; }
.toast { position: fixed; bottom: 1rem; right: 1rem; max-width: min(28rem, calc(100% - 2rem)); background: var(--night); color: #fff; padding: .75rem 1rem; border-radius: .5rem; }
@media (max-width: 840px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { padding: .8rem; gap: .7rem; }
  .sidebar nav { display: flex; overflow: auto; }
  .sidebar nav button { gap: .5rem; flex: none; }
  .sidebar footer { margin-top: 0; }
  .detail { grid-template-columns: minmax(0, 1fr); }
}
