/* ============================================================
   Fintrilo CRM — design system
   Use the variables; never hard-code a hex value in new code.
   ============================================================ */

:root {
  --bg:        #eef2f0;
  --surface:   #ffffff;
  --ink:       #14211d;
  --ink-2:     #4b5d57;
  --ink-3:     #7d8d87;
  --line:      #d6dfdb;
  --line-2:    #e7ecea;
  --green:     #1f6b4f;
  --green-2:   #2f8a67;
  --green-bg:  #e3f1ea;
  --amber:     #a86b12;
  --amber-bg:  #fbf0dc;
  --red:       #b42318;
  --red-bg:    #fbe7e5;
  --blue:      #2556a8;
  --blue-bg:   #e4ecfa;
  --radius-s:  4px;
  --radius-m:  8px;
  --shadow:    0 1px 2px rgba(20,33,29,.06), 0 4px 16px rgba(20,33,29,.06);
  --font:      'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
a { color: var(--green); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--green-2); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: var(--ink);
  color: #cfdad6;
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.wordmark { font-weight: 800; font-size: 19px; color: #fff; padding: 0 10px 18px; letter-spacing: -.01em; }
.wordmark span { color: #7fd1ad; font-weight: 600; }
.nav a {
  display: block; padding: 9px 10px; border-radius: var(--radius-s);
  color: #cfdad6; text-decoration: none; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: rgba(127,209,173,.14); color: #fff; box-shadow: inset 3px 0 0 #7fd1ad; }
.side .me { margin-top: auto; padding: 10px; font-size: 12px; color: #93a69f; border-top: 1px solid rgba(255,255,255,.08); }
.side .me b { display: block; color: #fff; font-weight: 600; font-size: 13px; }
.side .me button { margin-top: 8px; background: none; border: 1px solid rgba(255,255,255,.18); color: #cfdad6; padding: 4px 10px; border-radius: var(--radius-s); cursor: pointer; }

.main { padding: 26px 32px 80px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 750; letter-spacing: -.015em; }
.page-head .sub { color: var(--ink-2); margin-top: 2px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .wordmark { padding: 0 8px; }
  .nav { display: flex; flex-wrap: wrap; }
  .side .me { margin: 0 0 0 auto; border: 0; padding: 0 8px; }
  .side .me b { display: none; }
  .main { padding: 18px 14px 60px; }
}

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.panel + .panel, .grid + .panel, .panel + .grid { margin-top: 16px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.panel-h h2 { font-size: 15px; font-weight: 700; }
.panel-b { padding: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
.grid > .panel { margin-top: 0; }
@media (max-width: 1100px) { .grid.two { grid-template-columns: 1fr; } }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  padding: 7px 12px; border-radius: var(--radius-s);
  font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-2); }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: #fff;
  border-radius: var(--radius-s); padding: 7px 9px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-2); box-shadow: 0 0 0 3px var(--green-bg); }
label.f { display: block; }
label.f > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; }
.form-grid .wide { grid-column: 1 / -1; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; min-width: 150px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f6f9f8; }
table.t td.num, table.t th.num { text-align: right; }
table.t td .muted { display: block; font-size: 12px; }
.muted { color: var(--ink-3); }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-2); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; color: var(--ink-2); }

/* ---------- status chips ---------- */
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.chip.active { background: var(--blue-bg); color: var(--blue); }
.chip.won    { background: var(--green-bg); color: var(--green); }
.chip.dead, .chip.declined, .chip.rejected, .chip.expired, .chip.withdrawn { background: var(--red-bg); color: var(--red); }
.chip.bad, .chip.dnc { background: #ece9f5; color: #5a4a8a; }
.chip.approved, .chip.accepted { background: var(--green-bg); color: var(--green); }
.chip.pending_info, .chip.presented { background: var(--amber-bg); color: var(--amber); }
.chip.submitted { background: var(--blue-bg); color: var(--blue); }

/* ---------- the stage track: the one bold element ---------- */
.track { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin: 4px 0 18px; }
.track .st { position: relative; padding: 18px 6px 0; font-size: 11px; font-weight: 600; color: var(--ink-3); text-align: center; line-height: 1.2; }
.track .st::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 10px; background: var(--line); }
.track .st:first-child::before { border-radius: 5px 0 0 5px; }
.track .st:last-child::before  { border-radius: 0 5px 5px 0; }
.track .st.done::before { background: var(--green-2); }
.track .st.done { color: var(--ink-2); }
.track .st.now::before { background: var(--green); height: 14px; top: -2px; }
.track .st.now { color: var(--green); font-weight: 800; }
.track.off .st.done::before, .track.off .st.now::before { background: var(--ink-3); }
.track-note { margin: -10px 0 16px; font-size: 13px; color: var(--red); font-weight: 600; }
@media (max-width: 700px) { .track .st { font-size: 0; padding-top: 12px; } }

/* ---------- merchant header ---------- */
.m-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.m-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.m-head .sub { color: var(--ink-2); }
.m-head .ctl { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.m-head .ctl label.f { min-width: 170px; }
.back { display: inline-block; margin-bottom: 10px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 13px; }

/* key figures strip */
.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); margin-bottom: 16px; }
.figs div { padding: 12px 14px; border-right: 1px solid var(--line-2); }
.figs div:last-child { border-right: 0; }
.figs b { display: block; font-size: 18px; font-weight: 750; }
.figs small { color: var(--ink-3); font-size: 12px; }
.figs .warn b { color: var(--amber); }
.figs .bad b { color: var(--red); }

/* offers */
.offer { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; }
.offer + .offer { margin-top: 10px; }
.offer .big { font-size: 20px; font-weight: 800; }
.offer .kv { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--ink-2); font-size: 13px; grid-column: 1 / -1; }
.offer .kv b { color: var(--ink); font-weight: 650; }
.offer.accepted { border-color: var(--green-2); box-shadow: inset 4px 0 0 var(--green-2); }

/* fit list when submitting */
.fit { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line-2); align-items: start; }
.fit .why { font-size: 12px; color: var(--red); }
.fit .ok { font-size: 12px; color: var(--green); }
.fit.no { opacity: .7; }

/* notes */
.note { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.note:last-child { border-bottom: 0; }
.note .meta { font-size: 12px; color: var(--ink-3); margin-bottom: 2px; }
.note p { white-space: pre-wrap; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; }
.kpi b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.kpi span { color: var(--ink-2); font-size: 13px; }
.funnel-row { display: grid; grid-template-columns: 130px 1fr 50px; gap: 10px; align-items: center; padding: 5px 0; }
.funnel-row .bar { height: 12px; background: var(--line-2); border-radius: 6px; overflow: hidden; }
.funnel-row .bar i { display: block; height: 100%; background: var(--green-2); border-radius: 6px; }
.funnel-row.dead .bar i { background: var(--ink-3); }
.funnel-row .n { text-align: right; font-weight: 650; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(20,33,29,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius-m); box-shadow: var(--shadow); width: 100%; max-width: 640px; }
.modal.wide { max-width: 820px; }
.modal-h { padding: 16px 18px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; }
.modal-h h3 { font-size: 17px; }
.modal-h .x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--ink-3); line-height: 1; }
.modal-b { padding: 18px; }
.modal-f { padding: 14px 18px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; }
.calc-out { margin-top: 14px; background: var(--green-bg); border-radius: var(--radius-s); padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; }
.calc-out b { font-weight: 700; }

/* toast */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--radius-s); box-shadow: var(--shadow); max-width: 380px; }
.toast.err { background: var(--red); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 28px; display: grid; gap: 14px; }
.login h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.login h1 span { color: var(--green); }
.login p { color: var(--ink-2); }
.login .err { color: var(--red); font-size: 13px; }
.linklike { background: none; border: 0; color: var(--green); cursor: pointer; padding: 0; font-weight: 600; }

@media (prefers-reduced-motion: no-preference) {
  .modal { animation: pop .14s ease-out; }
  @keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
}
