/* Moneve Admin — light, soft CRM style. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --border: #e8eaee;
  --border-2: #dfe2e8;
  --text: #101828;
  --muted: #667085;
  --faint: #98a2b3;
  --accent: #101828;         /* primary buttons — soft black like modern CRMs */
  --accent-blue: #2e6be6;
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);

  /* pastel chips */
  --chip-gray-bg: #f2f4f7;   --chip-gray-fg: #475467;
  --chip-blue-bg: #e8f1fd;   --chip-blue-fg: #175cd3;
  --chip-purple-bg: #efedfd; --chip-purple-fg: #6941c6;
  --chip-green-bg: #e3f6e9;  --chip-green-fg: #027a48;
  --chip-red-bg: #feeceb;    --chip-red-fg: #b42318;
  --chip-amber-bg: #fdf3dc;  --chip-amber-fg: #b54708;
  --green: #12b76a;
  --red: #e04438;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--chip-red-fg); margin-top: 8px; font-size: 13px; }

/* ---------- login ---------- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px; width: 360px; display: flex; flex-direction: column; gap: 12px;
}
.login-logo {
  width: 76px; height: 76px; border-radius: 50%; background: var(--accent); color: #fff;
  align-items: center; justify-content: center; font-weight: 700; font-size: 30px;
  margin: 0 auto 4px;
}
.login-card { text-align: center; }
.login-card form { text-align: left; }
.login-card h1 { margin: 4px 0 0; font-size: 22px; }
.login-card p { margin: 0 0 6px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.small-note { font-size: 12.5px; }
.login-card a { color: var(--accent-blue); }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 8px; }
.brand-serif { font-family: "Cinzel", "Times New Roman", serif; letter-spacing: .5px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  display: block; background: var(--surface-2);
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px;
  flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 14.5px; }
.login-logo-img {
  width: 76px; height: 76px; border-radius: 50%; object-fit: cover;
  display: block; margin: 0 auto 4px; background: var(--surface-2);
}

#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group { color: var(--faint); font-size: 10.5px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; margin: 14px 10px 4px; }
.nav-group:first-child { margin-top: 0; }
#nav a {
  color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: var(--radius-s);
  font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 10px;
}
#nav a svg { width: 17px; height: 17px; stroke: currentColor; flex-shrink: 0; }
#nav a:hover { background: var(--surface-2); color: var(--text); }
#nav a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.who { color: var(--muted); font-size: 13px; padding: 0 10px; overflow: hidden; text-overflow: ellipsis; }

main { flex: 1; padding: 28px 32px; min-width: 0; }
.page-head { margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.page-head p { margin: 3px 0 0; font-size: 13.5px; }
h3 { margin: 0 0 12px; font-size: 14.5px; font-weight: 600; }

/* ---------- panels / cards ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px; overflow-x: auto;
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card .num { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.card .lbl { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.card .sub { color: var(--faint); font-size: 12px; margin-top: 3px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- controls ---------- */
.btn {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-2);
  border-radius: var(--radius-s); padding: 8px 14px; cursor: pointer; font-size: 13.5px; font-weight: 500;
  font-family: inherit; box-shadow: var(--shadow);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #232f45; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.danger { color: var(--chip-red-fg); }
.btn:disabled { opacity: .55; cursor: default; }
input, select, textarea {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-2);
  border-radius: var(--radius-s); padding: 8px 11px; font-size: 13.5px; font-family: inherit;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(46,107,230,.12); }
textarea { width: 100%; resize: vertical; margin: 8px 0; }
.panel > input[type=text], .panel > input[type=search] { width: 100%; margin-bottom: 8px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { min-width: 260px; }
.check { color: var(--muted); display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.field-row { display: flex; gap: 10px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.field-row label { color: var(--muted); font-size: 13px; }
.tabs { display: inline-flex; gap: 2px; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.tabs button {
  background: transparent; border: 0; color: var(--muted); padding: 6px 14px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 500; font-family: inherit;
}
.tabs button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td.wrap { white-space: normal; }
th { color: var(--faint); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
tbody tr.clickable { cursor: pointer; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 10px; color: var(--muted); font-size: 13px; }

/* ---------- chips ---------- */
.chip {
  display: inline-block; padding: 2.5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.chip.new        { background: var(--chip-blue-bg);   color: var(--chip-blue-fg); }
.chip.contacted  { background: var(--chip-amber-bg);  color: var(--chip-amber-fg); }
.chip.registered { background: var(--chip-purple-bg); color: var(--chip-purple-fg); }
.chip.deposited  { background: var(--chip-green-bg);  color: var(--chip-green-fg); }
.chip.lost       { background: var(--chip-red-bg);    color: var(--chip-red-fg); }
.chip.open       { background: var(--chip-blue-bg);   color: var(--chip-blue-fg); }
.chip.tp         { background: var(--chip-green-bg);  color: var(--chip-green-fg); }
.chip.be         { background: var(--chip-amber-bg);  color: var(--chip-amber-fg); }
.chip.sl         { background: var(--chip-red-bg);    color: var(--chip-red-fg); }
.chip.done       { background: var(--chip-green-bg);  color: var(--chip-green-fg); }
.chip.sending    { background: var(--chip-amber-bg);  color: var(--chip-amber-fg); }
.chip.scheduled  { background: var(--chip-blue-bg);   color: var(--chip-blue-fg); }
.chip.draft      { background: var(--chip-gray-bg);   color: var(--chip-gray-fg); }
.chip.failed, .chip.cancelled { background: var(--chip-red-bg); color: var(--chip-red-fg); }
.chip.admin      { background: var(--chip-purple-bg); color: var(--chip-purple-fg); }
.chip.affiliate  { background: var(--chip-blue-bg);   color: var(--chip-blue-fg); }
.dir-long { color: var(--chip-green-fg); font-weight: 700; }
.dir-short { color: var(--chip-red-fg); font-weight: 700; }

/* ---------- funnel ---------- */
.funnel-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.funnel-row .lbl { width: 120px; color: var(--muted); font-size: 13px; }
.funnel-row .bar-wrap { flex: 1; background: var(--surface-2); border-radius: 6px; height: 16px; overflow: hidden; }
.funnel-row .bar { height: 100%; background: var(--accent-blue); border-radius: 6px; min-width: 2px; opacity: .85; }
.funnel-row .val { width: 50px; text-align: right; font-weight: 600; font-size: 13px; }

/* ---------- feed ---------- */
.feed-item { display: flex; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: none; }
.feed-icon {
  width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0;
}
.feed-icon.tp { background: var(--chip-green-bg); }
.feed-icon.sl { background: var(--chip-red-bg); }
.feed-icon.be { background: var(--chip-amber-bg); }
.feed-icon.opened { background: var(--chip-blue-bg); }
.feed-body { min-width: 0; }
.feed-title { font-weight: 600; font-size: 13.5px; }
.feed-text { color: var(--muted); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 110px; overflow: hidden; margin-top: 2px; }
.feed-time { color: var(--faint); font-size: 12px; margin-left: auto; flex-shrink: 0; }

/* ---------- chats ---------- */
.chat-layout { display: grid; grid-template-columns: 330px 1fr; gap: 16px; height: calc(100vh - 210px); min-height: 420px; }
.chat-list { overflow-y: auto; padding: 8px; margin-bottom: 0; }
.chat-item { padding: 10px 12px; border-radius: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--surface-2); }
.chat-item .top { display: flex; justify-content: space-between; gap: 8px; }
.chat-item .name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .time { color: var(--faint); font-size: 11.5px; flex-shrink: 0; }
.chat-item .preview { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread { display: flex; flex-direction: column; margin-bottom: 0; overflow: hidden; }
.chat-head { padding-bottom: 12px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13.5px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px 4px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 72%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; box-shadow: var(--shadow); }
.msg.in { background: var(--surface-2); align-self: flex-start; border-bottom-left-radius: 5px; box-shadow: none; }
.msg.out { background: #e5efff; color: #16315e; align-self: flex-end; border-bottom-right-radius: 5px; box-shadow: none; }
.msg .meta { display: block; font-size: 11px; color: var(--faint); margin-top: 4px; }
.msg.out .meta { color: #5d7bad; }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; padding-top: 12px; border-top: 1px solid var(--border); }
.chat-compose textarea { flex: 1; margin: 0; }
.chat-compose select { max-width: 130px; }

/* ---------- drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.35); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 430px; max-width: 94vw;
  background: var(--surface); border-left: 1px solid var(--border); z-index: 50;
  padding: 22px; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.drawer h3 { margin: 0; font-size: 16px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 7px 10px; margin-bottom: 14px; font-size: 13.5px; }
.kv .k { color: var(--muted); }
.timeline-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.timeline-item:last-child { border-bottom: none; }
.timeline-item .t { color: var(--faint); font-size: 11.5px; }

/* ---------- misc ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff;
  padding: 10px 18px; border-radius: 10px; z-index: 100; box-shadow: var(--shadow-lg); font-size: 13.5px;
  max-width: 80vw;
}
.toast.err { background: var(--chip-red-fg); }
.list-item { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item .li-body { min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 13.5px; }
.list-item .li-text { color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.copy-link { color: var(--accent-blue); cursor: pointer; text-decoration: underline dotted; }
.progress-mini { color: var(--faint); font-size: 12.5px; margin-top: 2px; }
.avatar {
  width: 30px; height: 30px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.owner-select { font-size: 12.5px; padding: 4px 8px; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; }
  #nav { flex-direction: row; align-items: center; }
  .nav-group { display: none; }
  .sidebar-footer { border-top: none; padding-top: 0; flex-direction: row; }
  main { padding: 18px 14px; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-list { max-height: 300px; }
  .chat-thread { height: 60vh; }
}
