:root {
  --green: #01e49b;
  --blue: #0395eb;
  --lapis: #14295f;
  --paper: #f7f6f2;
  --pearl: #efeded;
  --ink: #191919;
  --coal: #666666;
  --line: #d9d6cf;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: var(--white);
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

button:hover,
button.active {
  background: var(--lapis);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--coal);
  font-size: 12px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 8vw, 56px);
  line-height: 0.96;
}

h2 {
  margin-bottom: 12px;
  font-size: 24px;
  line-height: 1.08;
}

.app-shell {
  display: grid;
  gap: 16px;
  width: min(960px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.identity-panel,
.view-panel,
.thread-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.identity-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.session-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 10px;
}

.session-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.session-summary span {
  display: block;
  margin-bottom: 3px;
  color: var(--coal);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.session-summary strong {
  color: var(--ink);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tabs button {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line);
}

.tabs button.active {
  background: var(--ink);
  color: var(--white);
}

.view-panel {
  padding: 16px;
}

.support-form,
.preferences-form,
.reply-form,
.attachment-section,
.attachment-list {
  display: grid;
  gap: 12px;
}

.history-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 14px;
}

.request-list,
.message-list {
  display: grid;
  gap: 10px;
}

.request-item {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.request-item.active,
.request-item:hover {
  background: #f3fbf8;
}

.thread-panel {
  min-height: 420px;
  padding: 16px;
}

.thread-heading {
  display: grid;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.next-step {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3fbf8;
  padding: 12px;
}

.next-step strong {
  color: var(--ink);
  font-size: 14px;
}

.next-step span {
  color: var(--coal);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  width: fit-content;
  border-radius: 999px;
  background: var(--green);
  color: var(--ink);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.pill.secondary {
  background: var(--pearl);
  color: var(--lapis);
}

.pill--status-open {
  background: var(--green);
  color: var(--ink);
}

.pill--status-acknowledged,
.pill--status-waiting-on-user,
.pill--status-waiting-on-provider {
  background: var(--blue);
  color: var(--white);
}

.pill--status-escalated {
  background: var(--lapis);
  color: var(--white);
}

.pill--status-resolved {
  background: var(--coal);
  color: var(--white);
}

.pill--status-closed {
  background: var(--ink);
  color: var(--white);
}

.pill--priority {
  background: var(--pearl);
  color: var(--lapis);
}

.pill--priority-low {
  background: var(--white);
  color: var(--coal);
  border: 1px solid var(--pearl);
}

.pill--priority-high {
  background: var(--white);
  color: var(--blue);
  border: 1px solid var(--blue);
}

.pill--priority-urgent {
  background: var(--blue);
  color: var(--white);
}

.message-list {
  padding: 14px 0;
}

.message-item {
  display: grid;
  gap: 4px;
  border-left: 3px solid var(--blue);
  padding-left: 10px;
}

.message-item p {
  margin-bottom: 0;
  line-height: 1.45;
}

.attachment-section {
  padding: 14px 0;
}

.attachment-section h3 {
  margin: 0;
  font-size: 16px;
}

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  padding: 10px;
}

.attachment-item span {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.meta {
  color: var(--coal);
  font-size: 12px;
  font-weight: 800;
}

.empty-state {
  display: grid;
  align-content: center;
  min-height: 320px;
  color: var(--coal);
}

.empty-state h2 {
  color: var(--ink);
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink);
  font-size: 14px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  padding: 0;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  border-radius: 8px;
  background: var(--lapis);
  color: var(--white);
  padding: 14px 16px;
  box-shadow: 0 16px 40px rgba(20, 41, 95, 0.22);
}

@media (max-width: 820px) {
  .app-shell {
    padding: 18px;
  }

  .app-header,
  .identity-panel,
  .session-form,
  .history-layout {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    grid-template-columns: 1fr;
  }

  .toast {
    position: static;
    max-width: none;
  }
}
