:root {
  color-scheme: light;
  --bg: #f2f5f5;
  --panel: #fff;
  --text: #172b37;
  --muted: #667780;
  --primary: #225b56;
  --primary-dark: #194742;
  --border: #dbe4e7;
  --danger: #873131;
  --shadow: 0 14px 38px rgba(20, 44, 57, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", sans-serif;
}

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

.customer-care-page {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 30px clamp(18px, 4vw, 56px) 56px;
}

.page-header, .brand, .panel-heading { display: flex; align-items: center; }
.page-header { justify-content: space-between; gap: 16px; padding-bottom: 26px; border-bottom: 1px solid var(--border); }
.brand { gap: 11px; color: var(--text); font-size: 1.05rem; font-weight: 800; text-decoration: none; }
.logo-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 10px; background: var(--primary); color: #fff; }
.back-link { color: var(--primary); font-size: 0.84rem; font-weight: 700; }
button.back-link { padding: 0; border: 0; background: transparent; cursor: pointer; }
.intro { padding: 34px 0 24px; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.1em; }
.intro h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.3rem); letter-spacing: -0.04em; }
.intro > p:last-child, .panel-heading p { margin: 7px 0 0; color: var(--muted); font-size: 0.85rem; line-height: 1.55; }
.customer-care-grid { display: grid; grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr); align-items: start; gap: 20px; }
.chat-column { display: grid; min-width: 0; gap: 20px; }
.panel { min-width: 0; padding: 22px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.panel-heading { justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.panel-heading h2 { margin: 0; font-size: 1.05rem; }
.panel-heading p { font-size: 0.77rem; }
form { display: grid; gap: 14px; }
.form-field { display: grid; gap: 6px; color: var(--text); font-size: 0.76rem; font-weight: 700; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--text);
  font-size: 0.82rem;
}
.form-field textarea { min-height: 140px; resize: vertical; }
.form-field small { color: var(--muted); font-size: 0.68rem; font-weight: 500; line-height: 1.5; }
.button { min-height: 40px; padding: 9px 13px; border: 1px solid transparent; border-radius: 8px; font-size: 0.8rem; font-weight: 700; cursor: pointer; }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(34, 91, 86, 0.2); outline-offset: 2px; }
.button:disabled { cursor: wait; opacity: 0.65; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--primary-dark); }
.button-secondary { border-color: var(--border); background: #fff; color: var(--text); }
.status-message { margin: 0 0 18px; padding: 12px 15px; border: 1px solid #e4c5c2; border-radius: 9px; background: #fff2f0; color: var(--danger); font-size: 0.86rem; line-height: 1.5; }
.status-message.success { border-color: #c2ded5; background: #eff8f4; color: #1c634d; }
.complaints-list { display: grid; gap: 12px; }
.chat-list-controls { display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin-bottom: 12px; color: var(--muted); font-size: 0.72rem; }
.chat-list-item {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.chat-list-item:hover, .chat-list-item.selected { border-color: var(--primary); background: #f2f8f6; }
.chat-list-item:focus-visible { outline: 3px solid rgba(34, 91, 86, 0.2); outline-offset: 2px; }
.chat-list-item strong { font-size: 0.82rem; }
.chat-list-meta, .chat-list-preview { color: var(--muted); font-size: 0.69rem; }
.chat-list-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-panel .panel-heading { align-items: flex-start; }
.chat-panel .panel-heading h2 { overflow-wrap: anywhere; }
.chat-messages {
  display: flex;
  min-height: 160px;
  max-height: min(52vh, 520px);
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #f8fafa;
}
.chat-bubble { max-width: min(85%, 560px); padding: 10px 12px; border-radius: 10px; }
.chat-bubble.from-customer { align-self: flex-end; background: #e7f2ef; }
.chat-bubble.from-admin { align-self: flex-start; background: #fff; border: 1px solid var(--border); }
.chat-bubble strong { display: block; font-size: 0.68rem; }
.chat-bubble p { margin: 5px 0; font-size: 0.8rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-bubble time { display: block; color: var(--muted); font-size: 0.62rem; }
.chat-message-form { margin-top: 14px; }
.chat-message-form textarea { min-height: 80px; resize: vertical; }
.chat-composer-actions, .attachment-controls { display: flex; align-items: center; gap: 10px; }
.chat-composer-actions { justify-content: space-between; flex-wrap: wrap; }
.attachment-controls { min-width: 0; flex-wrap: wrap; }
.attachment-name { max-width: min(320px, 55vw); overflow: hidden; color: var(--muted); font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.attachment-remove { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 50%; background: #fff; color: var(--text); cursor: pointer; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
.chat-attachment { display: grid; gap: 5px; max-width: min(100%, 360px); margin: 8px 0; }
.chat-attachment img { display: block; max-width: 100%; max-height: 260px; border: 1px solid var(--border); border-radius: 6px; object-fit: contain; }
.chat-attachment img[hidden] { display: none; }
.chat-attachment a { color: var(--primary); font-size: 0.76rem; font-weight: 700; overflow-wrap: anywhere; }
.button-danger { border-color: #ebc9c6; background: #fff2f0; color: #a33b3b; }
.button-danger:hover:not(:disabled) { background: #fde7e4; }
.complaint-card { padding: 15px; border: 1px solid var(--border); border-radius: 10px; background: #fbfcfc; }
.complaint-card h3 { margin: 0; font-size: 0.9rem; overflow-wrap: anywhere; }
.complaint-meta { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 6px; color: var(--muted); font-size: 0.69rem; }
.complaint-status { font-weight: 800; text-transform: capitalize; }
.complaint-message { margin: 12px 0 0; color: var(--text); font-size: 0.8rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.reply-message { margin: 12px 0 0; padding: 11px; border-left: 3px solid var(--primary); background: #eef5f3; }
.reply-message strong { display: block; font-size: 0.72rem; }
.reply-message p { margin: 5px 0 0; font-size: 0.78rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty-state { padding: 24px 10px; color: var(--muted); font-size: 0.82rem; text-align: center; }

@media (max-width: 800px) { .customer-care-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .customer-care-page { padding: 20px 14px 36px; }
  .panel { padding: 16px; }
  .panel-heading { align-items: flex-start; }
  .back-link { font-size: 0.75rem; }
}
