/* The CRM panel.
 *
 * Its own stylesheet rather than the admin panel's 31 KB: the screens here
 * are a list and one long page, and dragging in the styling for a listing
 * editor, a payout statement and a home-page builder to get a table would
 * make the lightest panel the heaviest. Same visual language, a quarter of
 * the weight.
 *
 * One deliberate difference from the other panels: this one is read while
 * somebody is on the phone, so the type is a step larger and the figures are
 * tabular, which stops a column of rupees from dancing as it loads. */

:root {
  --ink: #16181d;
  --muted: #5c6470;
  --line: #e3e0d8;
  --paper: #f6f5f1;
  --card: #fff;
  --brand: #fa7979;
  --good: #0d6b64;
  --warn: #a45a06;
  --bad: #a03328;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.boot { padding: 48px 20px; color: var(--muted); }
a { color: #1f3a5f; }

/* chrome */
header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
}
.brand { font-weight: 700; letter-spacing: -.01em; }
.brand span { color: var(--brand); }
.who { font-size: 13px; color: var(--muted); text-align: right; }
main { padding: 16px 20px 56px; max-width: 1200px; margin: 0 auto; }
@media (max-width: 640px) { main, header.top { padding-left: 16px; padding-right: 16px; } }

/* panels */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel > h2 { margin: 0 0 12px; font-size: 16px; }
.panel > h2 .muted { font-weight: 400; }
.split { display: grid; gap: 16px; grid-template-columns: 1fr; }
/* A grid child is min-width:auto, which means "as wide as my widest content"
 * -- so the orders table, which is meant to scroll inside its own box, made
 * the whole column wide instead and the page scrolled sideways with the
 * sidebar half off the screen. */
.split > * { min-width: 0; }
@media (min-width: 980px) { .split { grid-template-columns: 1.6fr 1fr; align-items: start; } }

/* tiles */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile span { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.tile small { color: var(--muted); font-size: 12px; }

/* filters */
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.bar input[type=search], .bar input[type=text] { min-width: 220px; flex: 1 1 220px; }
input, select, button, textarea { font: inherit; }
input[type=search], input[type=text], input[type=password], select, textarea {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
}
button { padding: 7px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
button:hover { border-color: #c8c4ba; }
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.link { border: 0; background: 0; padding: 0; color: #1f3a5f; text-decoration: underline; cursor: pointer; }

/* tables */
table { border-collapse: collapse; width: 100%; font-size: 14px; }
.scroll { overflow-x: auto; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #fbfaf7; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.who b { display: block; }
.nowrap { white-space: nowrap; }

/* bits */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pill { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); background: #f3f1ec; color: var(--muted); white-space: nowrap; }
.pill.paid, .pill.completed, .pill.active, .pill.customer { background: #e6f4f2; color: var(--good); border-color: #bfe1dd; }
.pill.unpaid, .pill.pending, .pill.new { background: #fdf3e3; color: var(--warn); border-color: #f0dcb7; }
.pill.cancelled, .pill.failed, .pill.cold, .pill.lost { background: #fdecea; color: var(--bad); border-color: #f3cfca; }
.pill.guess { background: #fdf3e3; color: var(--warn); border-color: #f0dcb7; }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 4px; background: #eef1f6; color: #1f3a5f; margin-right: 4px; }
.err { background: #fdecea; color: var(--bad); border: 1px solid #f3cfca; border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; }
.ok { background: #e6f4f2; color: var(--good); border: 1px solid #bfe1dd; border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; }
.note { background: #f3f1ec; border-radius: 6px; padding: 10px 12px; font-size: 13px; color: var(--muted); }

/* the one contact */
.head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; justify-content: space-between; }
.head h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.facts { display: grid; gap: 6px 18px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-top: 12px; font-size: 14px; }
.facts div span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* timeline */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 10px 0 10px 14px; border-left: 2px solid var(--line); margin-left: 4px; position: relative; }
.feed li::before { content: ''; position: absolute; left: -5px; top: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.feed li.in::before { background: var(--brand); }
.feed li.out::before { background: var(--good); }
.feed .when { font-size: 12px; color: var(--muted); }
.feed .what { font-size: 14px; }

/* login */
form.login { max-width: 340px; margin: 10vh auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
form.login h1 { margin: 0 0 2px; font-size: 20px; }
form.login .sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
form.login label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
form.login input { width: 100%; }
form.login button { width: 100%; margin-top: 16px; }

/* nav */
header.top nav.tabs { display: flex; gap: 4px; flex: 1; margin-left: 20px; }
header.top nav.tabs a {
  padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--muted);
  font-size: 14px; white-space: nowrap;
}
header.top nav.tabs a:hover { background: var(--sunk, #f1efe9); }
header.top nav.tabs a.on { background: var(--ink); color: #fff; }
.count {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 11px; font-weight: 600;
}
@media (max-width: 720px) {
  header.top { flex-wrap: wrap; }
  header.top nav.tabs { margin-left: 0; order: 3; width: 100%; }
}

/* writing */
textarea { width: 100%; resize: vertical; font-family: inherit; }
.bad { color: var(--bad); }
tr.late td { background: #fdf6f5; }

/* the merge question */
.warn-panel { border-color: #f0dcb7; background: #fffdf7; }
.candidate {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 10px 0; background: #fff;
}

/* messages read as messages */
.feed .what.msg .body { white-space: pre-wrap; margin-top: 2px; }
.feed li.in .what.msg .body { border-left: 3px solid var(--brand); padding-left: 8px; }
.feed li.out .what.msg .body { border-left: 3px solid var(--good); padding-left: 8px; }
.warn-note {
  background: #fdf3e3; color: var(--warn); border: 1px solid #f0dcb7;
  border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px;
}
.warn-note b { color: inherit; }
