:root {
  --ink: #17211d;
  --muted: #64746e;
  --line: #dfe9e3;
  --paper: #ffffff;
  --soft: #f4faf6;
  --green: #12624f;
  --green-2: #1f8f72;
  --yellow: #f2c84b;
  --blue: #2676d9;
  --coral: #df654b;
  --teal: #1997a5;
  --violet: #7a5cc9;
  --shadow: 0 18px 44px rgba(23, 33, 29, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(18, 98, 79, 0.09), rgba(38, 118, 217, 0.08) 38%, rgba(242, 200, 75, 0.12)),
    #f7fbf8;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 14px clamp(16px, 4vw, 34px);
  color: #fff;
  background: #12372d;
  box-shadow: 0 10px 30px rgba(18, 55, 45, 0.18);
}

.brand, .identity-pill, .board-top, .panel-heading {
  display: flex;
  align-items: center;
}

.brand { gap: 12px; min-width: 0; }

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #fff;
  object-fit: cover;
}

.brand h1, .panel-heading h2, .board-top h2, .login-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: clamp(1.35rem, 2.4vw, 1.9rem);
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 4px;
  color: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  opacity: 0.78;
}

.identity-pill {
  gap: 8px;
  max-width: 460px;
  min-height: 42px;
  padding: 6px 6px 6px 12px;
  color: #12372d;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(18, 55, 45, 0.12);
}

.identity-pill span:not(.identity-dot) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
}

main { padding: clamp(16px, 4vw, 34px); }

.login-view {
  display: grid;
  min-height: calc(100vh - 130px);
  place-items: center;
}

.login-panel {
  width: min(100%, 460px);
  padding: clamp(24px, 5vw, 42px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-icon {
  width: 86px;
  height: 86px;
  margin-bottom: 18px;
  border-radius: 8px;
  object-fit: cover;
}

.login-panel .eyebrow, .panel-heading .eyebrow, .board-top .eyebrow {
  color: var(--green);
}

.login-panel h2 {
  max-width: 360px;
  font-size: clamp(1.7rem, 5vw, 2.45rem);
  line-height: 1.05;
}

.login-form, .compose-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cddbd4;
  border-radius: 8px;
  outline: none;
}

input, select {
  height: 46px;
  padding: 0 12px;
}

textarea {
  min-height: 130px;
  padding: 12px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--green-2);
  box-shadow: 0 0 0 4px rgba(31, 143, 114, 0.14);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 26px);
  align-items: start;
}

.compose-panel, .board-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.compose-panel {
  position: sticky;
  top: 100px;
  padding: 20px;
}

.board-panel { padding: 20px; }

.panel-heading, .board-top {
  justify-content: space-between;
  gap: 12px;
}

.panel-heading { align-items: flex-start; }
.panel-heading h2, .board-top h2 { font-size: 1.35rem; }

.media-tools, .filters, .message-actions, .pending-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.media-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.primary-button, .secondary-button, .quiet-button, .alert-button, .tool-button, .filter-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--green);
  box-shadow: 0 10px 22px rgba(18, 98, 79, 0.2);
}

.primary-button:hover, .primary-button:focus-visible { background: #0e4f40; }

.secondary-button {
  padding: 0 14px;
  color: var(--green);
  background: #eaf5f0;
}

.quiet-button {
  min-width: 74px;
  padding: 0 10px;
  color: #12372d;
  background: #edf5f1;
}

.alert-button {
  min-width: 112px;
  padding: 0 11px;
  color: #12372d;
  background: #fff4ce;
}

.alert-button.is-on {
  color: #fff;
  background: #1f8f72;
}

.alert-button.needs-tap {
  color: #5b4310;
  background: #fff0b8;
}

.tool-button {
  padding: 0 10px;
  color: var(--ink);
  background: #f7f9f8;
  border: 1px solid #d7e4dc;
}

.tool-button:nth-child(1) { border-color: rgba(38,118,217,.35); background: #edf5ff; }
.tool-button:nth-child(2) { border-color: rgba(31,143,114,.35); background: #edf8f3; }
.tool-button:nth-child(3) { border-color: rgba(223,101,75,.35); background: #fff0ec; }
.tool-button:nth-child(4) { border-color: rgba(122,92,201,.35); background: #f2efff; }

.tool-button.is-recording {
  color: #fff;
  background: var(--coral);
}

.pending-files {
  padding: 10px;
  background: #f6faf8;
  border: 1px dashed #cddbd4;
  border-radius: 8px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 7px 8px 7px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.file-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip button {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  color: var(--muted);
  background: #eef4f1;
  border: 0;
  border-radius: 50%;
}

.filters { margin: 18px 0 12px; }

.filter-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--muted);
  background: #f5f8f6;
  border: 1px solid #dce8e2;
}

.filter-button.is-active {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.filter-button span {
  min-width: 24px;
  padding: 2px 6px;
  color: inherit;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.search-row { margin-bottom: 14px; }

.mode-notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  color: #5b4310;
  background: #fff6d9;
  border: 1px solid #f0d88a;
  border-radius: 8px;
  font-weight: 700;
}

.message-list {
  display: grid;
  gap: 14px;
}

.message-card {
  --dept-color: var(--green);
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 8px solid var(--dept-color);
  border-radius: 8px;
  box-shadow: 0 10px 22px rgba(23, 33, 29, 0.07);
}

.message-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.route-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.dept-badge, .status-badge, .forwarded-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.dept-badge {
  color: #0f3229;
  background: var(--dept-bg, #eaf5f0);
}

.status-badge {
  color: #fff;
  background: var(--coral);
}

.status-badge.done { background: var(--green-2); }

.forwarded-badge {
  color: #4b3b09;
  background: #fff1ba;
}

.message-time {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.sender-line {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.message-body {
  margin: 14px 0 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.done-line {
  margin: 12px 0 0;
  color: #12624f;
  font-weight: 800;
}

.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.attachment {
  min-width: 0;
  overflow: hidden;
  background: #f7faf8;
  border: 1px solid #dbe8e1;
  border-radius: 8px;
}

.attachment img, .attachment video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #eaf0ed;
}

.attachment audio {
  display: block;
  width: 100%;
  padding: 10px;
}

.attachment a, .attachment-file {
  display: block;
  padding: 12px;
  color: var(--green);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.comments {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.comment {
  padding: 10px 12px;
  background: #f5f9f7;
  border: 1px solid #e0ebe5;
  border-radius: 8px;
}

.comment strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.85rem;
}

.comment p {
  margin: 0;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.message-actions {
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #edf3ef;
}

.comment-form, .forward-form {
  display: flex;
  gap: 8px;
  min-width: min(100%, 360px);
  flex: 1 1 280px;
}

.comment-form input, .forward-form select { height: 40px; }

.comment-form button, .forward-form button, .done-button {
  min-height: 40px;
  padding: 0 12px;
  color: #fff;
  background: var(--green);
  border: 0;
  border-radius: 8px;
  font-weight: 900;
  white-space: nowrap;
}

.forward-form button { background: var(--blue); }
.done-button { background: var(--green-2); }

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
  background: #fff;
  border: 1px dashed #cddbd4;
  border-radius: 8px;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(92vw, 420px);
  padding: 12px 14px;
  color: #fff;
  background: #12372d;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-weight: 800;
}

[hidden] { display: none !important; }

@media (max-width: 880px) {
  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
  }

  .identity-pill { max-width: none; }
  .workspace { grid-template-columns: 1fr; }
  .compose-panel { position: static; }
}

@media (max-width: 560px) {
  main { padding: 12px; }
  .topbar { padding: 12px; }
  .brand-icon { width: 42px; height: 42px; }
  .compose-panel, .board-panel, .message-card { padding: 14px; }
  .board-top, .message-header { grid-template-columns: 1fr; }
  .message-time { text-align: left; }
  .media-tools { grid-template-columns: 1fr 1fr; }
  .comment-form, .forward-form { flex-basis: 100%; }
  .comment-form { flex-direction: column; }
  .comment-form button, .forward-form button, .done-button { width: 100%; }
}
