:root {
  --accent: #c8342f;       /* tinted per brand by app.js */
  --charcoal: #2b2f36;
  --paper: #f6f4ef;
  --ink: #23262b;
  --line: #e2ddd2;
  --muted: #7a7f88;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
h1, h2, h3, h4 { font-weight: 700; margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: #b3261e; font-size: 13px; }
.notice { font-size: 13px; padding: 8px 12px; border-radius: 8px; background: #fff; border: 1px solid var(--line); }

/* ---------- login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--charcoal);
}
.login-card {
  background: var(--paper); border-radius: 14px; padding: 36px 32px;
  width: 340px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-mark {
  width: 52px; height: 52px; border-radius: 12px; background: var(--accent);
  color: #fff; font-weight: 800; font-size: 20px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.login-card label { display: block; font-size: 13px; margin: 14px 0 0; color: var(--muted); }
.login-card input {
  width: 100%; margin-top: 6px; padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--charcoal); color: #d9dce1;
  display: flex; flex-direction: column; padding: 14px 12px;
}
.sidebar-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 16px; }
.brand-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); flex: none; }
#brandSwitcher {
  flex: 1; background: #3a3f48; color: #fff; border: none; border-radius: 8px;
  padding: 8px; font-size: 13px; font-weight: 600;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  text-align: left; background: none; border: none; color: #c3c8d0;
  padding: 10px 12px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.badge {
  background: #fff; color: var(--accent); border-radius: 10px;
  font-size: 11px; padding: 1px 7px; margin-left: 6px; font-weight: 700;
}
.sidebar-foot { padding-top: 12px; }

.content { flex: 1; padding: 22px 28px; max-width: 1150px; }
.topbar { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.stats { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.stats b { color: var(--ink); }

/* ---------- cards, forms, tables ---------- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 18px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin: 12px 0; }
.form-grid label, .brand-card label { font-size: 12px; color: var(--muted); display: block; }
input, select {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #fff; width: 100%;
}
.row { display: flex; gap: 10px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.row input, .row select { width: auto; flex: 1; min-width: 120px; }
.space-between { justify-content: space-between; }
.btn {
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; font-size: 14px; cursor: pointer; font-weight: 600; color: var(--ink);
  flex: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(.92); color: #fff; }
.btn.ghost { background: transparent; color: #c3c8d0; border-color: #4a4f58; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.full { width: 100%; margin-top: 18px; }
.btn.danger { color: #b3261e; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px 10px; border-bottom: 1px solid #f0ece3; }
.tag-chip { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px; font-size: 11px; margin-right: 4px; display: inline-block; }
.status-pill { border-radius: 10px; padding: 2px 9px; font-size: 11px; font-weight: 700; }
.status-APPROVED, .status-done, .status-delivered, .status-read, .status-sent { background: #e4f2e9; color: #1f6f54; }
.status-PENDING, .status-sending, .status-queued { background: #fdf3dc; color: #8a6d1a; }
.status-REJECTED, .status-failed { background: #fbe4e2; color: #b3261e; }

/* ---------- inbox ---------- */
.inbox { display: flex; gap: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; height: calc(100vh - 140px); }
.conv-list { width: 280px; border-right: 1px solid var(--line); overflow-y: auto; }
.conv-item { padding: 12px 14px; border-bottom: 1px solid #f0ece3; cursor: pointer; }
.conv-item:hover, .conv-item.active { background: var(--paper); }
.conv-item .who { font-weight: 600; font-size: 14px; }
.conv-item .when { font-size: 11px; color: var(--muted); }
.conv-pane { flex: 1; display: flex; flex-direction: column; }
.conv-head { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; }
.conv-messages { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; background: var(--paper); }
.msg { max-width: 65%; padding: 9px 13px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; }
.msg.out { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.msg.in { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg .meta { font-size: 10px; opacity: .7; margin-top: 4px; }
/* Whatever somebody sent us: a photo of a broken screen, a voice note, a PDF. */
.msg .shot { display: block; max-width: 260px; max-height: 320px; width: auto;
             border-radius: 8px; margin-bottom: 6px; cursor: zoom-in; }
.msg .clip { display: block; max-width: 260px; margin-bottom: 6px; }
.msg .file { display: inline-block; margin-bottom: 6px; font-weight: 600;
             text-decoration: underline; }
.msg.in .file { color: var(--accent); }
.msg.out .file { color: #fff; }
.conv-reply { display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.conv-reply input { flex: 1; }

/* ---------- settings brand cards ---------- */
.brand-card { border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 10px; padding: 14px 16px; margin: 10px 0; }
.brand-card .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.brand-card h4 { margin: 0; }
code.small { font-size: 11px; background: var(--paper); padding: 2px 6px; border-radius: 6px; word-break: break-all; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .form-grid, .brand-card .grid { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .conv-list { width: 200px; }
}
