* {
  box-sizing: border-box;
}
:root {
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  color: #202e2c;
  background: #f5f7f5;
  --green: #165a46;
  --line: #dce4df;
  --muted: #566a62;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
}
button,
a,
input,
select,
textarea {
  outline-offset: 3px;
}
button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 9px 14px;
  color: #233d32;
  font-weight: 600;
}
button:hover {
  background: #edf3ef;
}
button:disabled {
  opacity: 0.55;
  cursor: default;
}
.primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
.primary:hover {
  background: #104634;
}
input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid #c4d1c9;
  background: #fff;
  color: #182d23;
}
label {
  display: grid;
  gap: 6px;
  color: #45594f;
  font-size: 0.87rem;
  font-weight: 600;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: clamp(1.65rem, 2.6vw, 2.25rem);
  font-weight: 650;
  letter-spacing: -0.05em;
}
h2 {
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}
small,
.muted {
  color: var(--muted);
}
small {
  font-size: 0.8rem;
}
a {
  color: var(--green);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 1.18rem;
  font-weight: 670;
  letter-spacing: -0.04em;
}
.mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px 10px 10px 2px;
  background: #c1edba;
  color: #173e32;
  font-size: 17px;
  font-weight: 780;
  letter-spacing: -2px;
  padding-right: 2px;
}
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: #edf3ee;
  padding: 20px;
}
.login-box {
  width: min(100%, 390px);
  background: white;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.login-box .brand {
  margin-bottom: 38px;
}
.login-box h1 {
  margin-bottom: 22px;
}
form.stack {
  display: grid;
  gap: 17px;
}
.shell {
  display: grid;
  grid-template-columns: 222px minmax(0, 1fr);
  min-height: 100dvh;
}
.rail {
  background: #133b33;
  color: white;
  padding: 28px 17px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.rail .brand {
  padding: 0 7px;
}
.rail nav {
  display: grid;
  gap: 6px;
}
.rail nav button,
.rail footer button {
  background: none;
  color: #d1dfd7;
  border: 0;
  text-align: left;
}
.rail nav button.active,
.rail nav button:hover {
  background: #2c554a;
  color: white;
}
.rail footer {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding: 12px 4px;
}
.rail footer small {
  color: #b6cec0;
}
.rail footer button {
  padding-left: 0;
}
main {
  padding: clamp(18px, 3vw, 42px);
  min-width: 0;
}
.top,
.row,
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.top,
.row {
  justify-content: space-between;
}
.top {
  margin-bottom: 24px;
}
.top small {
  display: block;
  margin-bottom: 5px;
}
.panel,
.inbox {
  background: white;
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
}
.panel .row {
  padding: 18px 21px;
  border-bottom: 1px solid var(--line);
}
.panel .row:last-child {
  border-bottom: 0;
}
.row h3 {
  font-size: 1rem;
}
.row small {
  display: block;
  margin-top: 5px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 30px;
  background: #edf2ef;
  padding: 4px 9px;
  font-size: 0.75rem;
  color: #50645a;
  white-space: nowrap;
}
.badge.online,
.badge.auto {
  background: #dff2e5;
  color: #225d3c;
}
.badge.waiting,
.badge.offline,
.badge.qr {
  background: #fff0d9;
  color: #80520a;
}
.empty {
  margin: auto;
  padding: 32px;
  display: grid;
  gap: 7px;
  text-align: center;
  color: #65796d;
}
.empty strong {
  color: #304a3a;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 13px;
}
.filters > * {
  width: auto;
  max-width: 100%;
}
.filters input {
  min-width: 130px;
  flex: 1;
}
.inbox {
  display: grid;
  grid-template-columns: minmax(210px, 32%) minmax(0, 1fr);
  height: calc(100dvh - 185px);
  min-height: 390px;
}
.chatlist {
  overflow-y: auto;
  border-right: 1px solid var(--line);
}
.chat {
  display: block;
  width: 100%;
  text-align: left;
  background: white;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  padding: 15px 16px;
  line-height: 1.4;
}
.chat.selected {
  background: #edf6ef;
  box-shadow: inset 3px 0 #257454;
}
.chat .row {
  gap: 4px;
}
.chat small,
.chat .preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview {
  font-size: 0.86rem;
  color: #52695d;
  font-weight: 400;
  margin-top: 5px;
}
.thread {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.threadhead {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.stream {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  background: #f6f8f5;
}
.bubble {
  max-width: 83%;
  border: 1px solid var(--line);
  padding: 10px 13px;
  border-radius: 11px;
  align-self: flex-start;
  background: white;
  overflow-wrap: anywhere;
}
.bubble.out {
  align-self: flex-end;
  background: #e2f0e4;
}
.bubble p {
  white-space: pre-wrap;
  margin: 3px 0;
}
.bubble audio,
.bubble img {
  max-width: 100%;
}
.bubble img {
  max-height: 200px;
}
.stamp {
  font-size: 0.72rem;
  color: #5c7162;
}
.compose {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.compose textarea {
  resize: vertical;
  min-height: 42px;
}
.reason {
  padding: 8px 16px;
  background: #fff4df;
  font-size: 0.85rem;
  color: #6b4c16;
}
dialog {
  width: min(410px, 94vw);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}
dialog::backdrop {
  background: #102d256b;
}
dialog h2 {
  margin-bottom: 18px;
}
dialog .actions {
  justify-content: flex-end;
}
dialog img {
  display: block;
  max-width: 100%;
  margin: 0 auto 14px;
}
#notice:not(:empty) {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 19px;
  border-radius: 9px;
  color: white;
  background: #183e32;
  box-shadow: 0 4px 20px #1232;
  z-index: 9;
}
@media (max-width: 800px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .rail {
    padding: 12px 16px;
    gap: 8px;
  }
  .rail nav {
    display: flex;
    overflow: auto;
  }
  .rail nav button {
    white-space: nowrap;
  }
  .rail footer {
    display: flex;
    position: absolute;
    top: 8px;
    right: 12px;
    padding: 0;
  }
  .rail footer strong,
  .rail footer small {
    display: none;
  }
  .inbox {
    height: 65dvh;
  }
  .actions {
    flex-wrap: wrap;
  }
  .panel .row {
    align-items: flex-start;
    flex-wrap: wrap;
  }
}
@media (max-width: 600px) {
  main {
    padding: 16px 10px;
  }
  .inbox {
    display: flex;
    flex-direction: column;
    height: auto;
  }
  .chatlist {
    max-height: 230px;
    border-right: 0;
  }
  .thread {
    min-height: 325px;
  }
  .stream {
    max-height: 55dvh;
  }
  .filters select {
    max-width: 48%;
  }
  .filters input {
    flex-basis: 100%;
  }
  .row {
    gap: 8px;
  }
  .threadhead {
    padding: 10px;
  }
  .badge {
    font-size: 0.7rem;
  }
}
@media (max-width: 800px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .rail {
    min-width: 0;
  }
  .rail nav {
    min-width: 0;
    max-width: 100%;
  }
  .top {
    flex-wrap: wrap;
  }
}

.panel .actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}
.download {
  font-weight: 600;
}
dialog code {
  display: block;
  padding: 12px 0;
  user-select: all;
}
@media (max-width: 480px) {
  .rail footer {
    position: static;
    padding: 0;
  }
}
