:root {
  --bg: #f4efe6;
  --panel: rgba(255, 252, 247, 0.92);
  --panel-strong: #fffdf8;
  --line: rgba(68, 51, 32, 0.12);
  --text: #1f1a17;
  --muted: #6f655d;
  --blue: #2e6cf6;
  --red: #d64545;
  --yellow: #d5a100;
  --green: #1d8f53;
  --shadow: 0 20px 60px rgba(88, 61, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Manrope', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(46, 108, 246, 0.14), transparent 24%),
    radial-gradient(circle at bottom right, rgba(214, 69, 69, 0.12), transparent 22%),
    linear-gradient(180deg, #f7f2e9 0%, var(--bg) 100%);
}

button,
textarea,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 249, 241, 0.86);
  backdrop-filter: blur(24px);
  padding: 28px 20px;
  overflow: auto;
}

.sidebar-header h1,
.detail-header h2 {
  margin: 0;
  font-size: 32px;
  line-height: 1.05;
}

.eyebrow,
.card-label,
.queue-meta,
.status-message {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
}

.sidebar-copy {
  color: var(--muted);
  line-height: 1.5;
}

.toolbar {
  display: grid;
  gap: 12px;
  margin: 24px 0 14px;
}

.search-input,
.editor-textarea {
  width: 100%;
  border: 1px solid rgba(68, 51, 32, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  padding: 14px 16px;
  outline: none;
}

.search-input:focus,
.editor-textarea:focus {
  border-color: rgba(46, 108, 246, 0.5);
  box-shadow: 0 0 0 4px rgba(46, 108, 246, 0.08);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-chip,
.ghost-button,
.primary-button,
.danger-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.filter-chip,
.ghost-button {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  padding: 10px 14px;
  border: 1px solid var(--line);
}

.filter-chip.is-active {
  background: var(--text);
  color: #fff;
}

.primary-button,
.danger-button {
  color: #fff;
  padding: 14px 18px;
  min-width: 170px;
  box-shadow: var(--shadow);
}

.primary-button {
  background: linear-gradient(135deg, #2457db 0%, var(--blue) 100%);
}

.danger-button {
  background: linear-gradient(135deg, #aa2f2f 0%, var(--red) 100%);
}

button:hover {
  transform: translateY(-1px);
}

.queue-list {
  display: grid;
  gap: 12px;
  padding-bottom: 24px;
}

.queue-item {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid transparent;
  border-radius: 24px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(88, 61, 36, 0.08);
}

.queue-item.is-active {
  border-color: rgba(46, 108, 246, 0.35);
  background: var(--panel-strong);
}

.queue-item-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
}

.queue-item-subject {
  margin: 8px 0;
  color: var(--muted);
  font-size: 14px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: white;
}

.badge.delivery { background: var(--blue); }
.badge.complaint { background: var(--red); }
.badge.missing { background: var(--yellow); color: #2f2419; }
.badge.ready { background: var(--green); }

.detail-panel {
  padding: 28px;
}

.empty-state,
.detail-view {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 32px;
  box-shadow: var(--shadow);
  min-height: calc(100vh - 56px);
  padding: 28px;
}

.hidden {
  display: none;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.detail-customer {
  margin: 0 0 8px;
  color: var(--muted);
}

.detail-actions-top,
.decision-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.info-grid,
.context-grid,
.editor-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.info-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.editor-grid {
  grid-template-columns: 1.4fr 1fr;
}

.context-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-card,
.editor-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
}

.wide-card {
  grid-column: 1 / -1;
}

.card-body,
.thread-list {
  margin-top: 10px;
  line-height: 1.6;
}

.list-body ul,
.thread-list ul {
  margin: 0;
  padding-left: 18px;
}

.editor-textarea {
  min-height: 180px;
  resize: vertical;
  margin-top: 10px;
}

.editor-textarea.compact {
  min-height: 110px;
}

.inline-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.thread-entry {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.thread-entry:last-child {
  border-bottom: 0;
}

.thread-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.decision-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}

.status-message {
  min-height: 1.2em;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .detail-panel {
    padding-top: 0;
  }
}

@media (max-width: 760px) {
  .detail-header,
  .decision-bar,
  .editor-grid,
  .info-grid,
  .context-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .detail-actions-top,
  .decision-actions {
    width: 100%;
  }

  .primary-button,
  .danger-button,
  .ghost-button {
    width: 100%;
  }
}
