:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #20242c;
  --muted: #657083;
  --accent: #0b6b57;
  --accent-strong: #094f42;
  --warn: #a13f19;
  --bubble-me: #e8f4f0;
  --bubble-other: #f1f3f6;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  border-color: var(--line);
  background: #d8dde4;
  color: #6c7480;
  cursor: not-allowed;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
}

.login-screen {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 360px);
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-form h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.form-error {
  margin: 0;
  color: var(--warn);
  font-size: 14px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.app-header h1 {
  margin: 0;
  font-size: 20px;
}

.app-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  height: calc(100vh - 72px);
  min-height: 0;
}

.chat-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  min-width: 0;
  min-height: 0;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.chat-list {
  overflow: auto;
}

.chat-item {
  width: 100%;
  display: grid;
  gap: 5px;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.chat-item:hover,
.chat-item.is-active {
  background: #edf3f1;
  color: var(--text);
}

.chat-item strong,
.chat-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item strong {
  font-size: 14px;
}

.chat-item span {
  color: var(--muted);
  font-size: 12px;
}

.wide-button {
  width: calc(100% - 24px);
  margin: 12px;
}

.message-column {
  min-width: 0;
  min-height: 0;
  background: #fbfcfd;
}

.empty-state {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
}

.message-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.message-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.message-toolbar h2 {
  margin: 0;
  font-size: 17px;
}

.message-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.message-list {
  overflow: auto;
  padding: 14px 16px 28px;
}

.message {
  display: grid;
  gap: 5px;
  max-width: min(760px, 92%);
  margin: 0 0 10px;
}

.message.manager {
  margin-left: auto;
}

.message-meta {
  color: var(--muted);
  font-size: 12px;
}

.message-bubble {
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--bubble-other);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.manager .message-bubble {
  background: var(--bubble-me);
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachments a {
  display: inline-flex;
}

.attachments .file-attachment {
  color: #0645ad;
  text-decoration: underline;
}

.attachments img {
  max-width: min(220px, 100%);
  max-height: 220px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: contain;
  background: #fff;
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 38vh) minmax(0, 1fr);
    height: calc(100vh - 118px);
  }

  .chat-column {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .message-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
