/* Referral Desk
   Neutral on purpose. This tool sits between a lead source and the agencies receiving them, and
   any brand personality here is a clue about who is running it. Indigo accent, slate ink, warm
   paper surfaces: it should read as infrastructure, not as somebody's product. */

:root {
  --ink: #101725;
  --ink-2: #3d4759;
  --ink-3: #6b7688;
  --line: #e3e6ec;
  --line-2: #eef0f4;
  --paper: #f7f8fa;
  --card: #ffffff;
  --rail: #141b2b;
  --rail-2: #1e2739;
  --rail-ink: #aeb7c7;

  --accent: #4f46e5;
  --accent-2: #4338ca;
  --accent-wash: #eef0fe;

  --green: #157a4b; --green-w: #e6f5ee;
  --amber: #96620a; --amber-w: #fdf3e1;
  --rose:  #b3253c; --rose-w:  #fdeef0;
  --sky:   #0f6a91; --sky-w:   #e6f4fb;
  --slate: #55607a; --slate-w: #eef0f4;
  --indigo:#4338ca; --indigo-w:#eceafe;

  --r: 10px;
  --r-lg: 14px;
  --sh-1: 0 1px 2px rgb(16 23 37 / .05);
  --sh-2: 0 1px 2px rgb(16 23 37 / .06), 0 6px 18px -6px rgb(16 23 37 / .10);
  --sh-3: 0 2px 4px rgb(16 23 37 / .05), 0 18px 40px -12px rgb(16 23 37 / .22);
  --rail-w: 232px;
  --ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.5 var(--ui);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.011em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 99; background: var(--card); padding: .6rem .9rem; border-radius: var(--r); box-shadow: var(--sh-3); }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
}

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.main-wrap { min-width: 0; display: flex; flex-direction: column; }

.rail {
  background: var(--rail); color: var(--rail-ink);
  display: flex; flex-direction: column; gap: .25rem;
  position: sticky; top: 0; height: 100vh;
}
.rail__brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.1rem .9rem; color: #fff; font-weight: 650; letter-spacing: -.01em; }
.mark { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(150deg, #6366f1, #4338ca); flex: none; box-shadow: inset 0 1px 0 rgb(255 255 255 / .25); }
.rail__close { display: none; margin-left: auto; background: none; border: 0; color: inherit; font-size: 1.5rem; line-height: 1; cursor: pointer; }

.rail__nav { display: grid; gap: 2px; padding: .35rem .6rem; }
.rail__nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .65rem; border-radius: 8px;
  text-decoration: none; color: var(--rail-ink); font-size: .93rem; font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.rail__nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.rail__nav a:hover { background: var(--rail-2); color: #fff; }
.rail__nav a[aria-current="page"] { background: var(--rail-2); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }

.rail__foot { margin-top: auto; padding: .8rem; border-top: 1px solid rgb(255 255 255 / .07); }
.who { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  background: var(--rail-2); color: #fff;
}
.who__t { min-width: 0; display: grid; }
.who__t b { color: #fff; font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who__t em { font-style: normal; font-size: .76rem; opacity: .7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout { display: block; margin-top: .6rem; font-size: .82rem; text-decoration: none; opacity: .75; }
.signout:hover { opacity: 1; text-decoration: underline; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1.5rem;
  background: rgb(247 248 250 / .88); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.12rem; }
.burger { display: none; background: none; border: 0; padding: .35rem; cursor: pointer; }
.burger svg { width: 22px; height: 22px; }
.search { margin-left: auto; position: relative; }
.search svg { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--ink-3); }
.search input {
  width: 300px; max-width: 42vw; padding: .48rem .7rem .48rem 2.1rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
}
.search input::placeholder { color: var(--ink-3); }

.main { padding: 1.5rem; display: grid; gap: 1.25rem; align-content: start; }

.flash {
  padding: .7rem 1rem; border-radius: var(--r);
  background: var(--green-w); color: var(--green);
  border: 1px solid color-mix(in srgb, var(--green) 22%, transparent);
  font-size: .92rem; font-weight: 500;
}

/* ---------------------------------------------------------------- bits */
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 650; letter-spacing: .01em; white-space: nowrap;
}
.pill--slate  { background: var(--slate-w);  color: var(--slate); }
.pill--indigo { background: var(--indigo-w); color: var(--indigo); }
.pill--sky    { background: var(--sky-w);    color: var(--sky); }
.pill--amber  { background: var(--amber-w);  color: var(--amber); }
.pill--green  { background: var(--green-w);  color: var(--green); }
.pill--rose   { background: var(--rose-w);   color: var(--rose); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid transparent;
  font-size: .9rem; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-2); }
.btn--line { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn--line:hover { border-color: var(--ink-3); }
.btn--danger { background: var(--card); border-color: color-mix(in srgb, var(--rose) 30%, transparent); color: var(--rose); }
.btn--danger:hover { background: var(--rose-w); }
.btn--sm { padding: .3rem .6rem; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card__hd { padding: .85rem 1.1rem; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: .75rem; }
.card__hd h2 { font-size: .98rem; }
.card__hd .btn { margin-left: auto; }
.card__b { padding: 1.1rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .9rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: .9rem 1rem; box-shadow: var(--sh-1); }
.kpi b { display: block; font-size: 1.7rem; line-height: 1.1; letter-spacing: -.02em; }
.kpi span { display: block; margin-top: .15rem; font-size: .8rem; color: var(--ink-3); font-weight: 500; }

.empty { text-align: center; padding: 3rem 1.5rem; color: var(--ink-3); }
.empty h2 { font-size: 1.05rem; color: var(--ink-2); }
.empty p { margin: .4rem 0 1rem; font-size: .92rem; max-width: 46ch; margin-inline: auto; }

/* ---------------------------------------------------------------- board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(258px, 1fr); gap: .85rem; align-items: start; overflow-x: auto; padding-bottom: .6rem; }
.col { background: var(--line-2); border-radius: var(--r-lg); min-height: 120px; display: flex; flex-direction: column; }
.col__hd { display: flex; align-items: center; gap: .5rem; padding: .7rem .8rem .5rem; font-size: .82rem; font-weight: 650; color: var(--ink-2); }
.col__n { margin-left: auto; background: var(--card); border-radius: 999px; padding: .05rem .45rem; font-size: .74rem; color: var(--ink-3); }
.col__b { display: grid; gap: .5rem; padding: 0 .55rem .55rem; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -3px; }

.lcard {
  display: block; text-decoration: none; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r); padding: .7rem .75rem;
  box-shadow: var(--sh-1); cursor: grab;
  transition: box-shadow .12s ease, transform .12s ease, border-color .12s ease;
}
.lcard:hover { box-shadow: var(--sh-2); border-color: #d6dae2; }
.lcard.dragging { opacity: .45; transform: rotate(1deg); }
.lcard__t { display: flex; align-items: baseline; gap: .5rem; }
.lcard__t b { font-size: .92rem; font-weight: 620; }
.lcard__t time { margin-left: auto; font-size: .72rem; color: var(--ink-3); white-space: nowrap; }
.lcard__m { margin: .3rem 0 0; font-size: .8rem; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: .15rem .55rem; }
.lcard__f { margin-top: .5rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.tag { font-size: .72rem; background: var(--line-2); color: var(--ink-2); border-radius: 5px; padding: .12rem .4rem; }
.tag--st { background: var(--accent-wash); color: var(--accent-2); font-weight: 650; }

/* ---------------------------------------------------------------- table */
.tablewrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .89rem; }
.grid th, .grid td { padding: .62rem .8rem; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.grid th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 650; background: #fbfbfd; position: sticky; top: 0; }
.grid tbody tr:hover { background: #fbfbfd; }
.grid td a.name { font-weight: 620; text-decoration: none; }
.grid td a.name:hover { color: var(--accent); text-decoration: underline; }
.grid .num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filters select, .filters input {
  padding: .42rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card);
}

/* ---------------------------------------------------------------- forms */
.form { display: grid; gap: .9rem; max-width: 560px; }
.f { display: grid; gap: .3rem; }
.f label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.f input, .f select, .f textarea {
  padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); width: 100%;
}
.f textarea { min-height: 90px; resize: vertical; }
.f .hint { font-size: .78rem; color: var(--ink-3); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
/* A checkbox and its label are one control, so they sit on one line and the whole line is the
   hit target. Left to the generic .f grid rules they stack and the box floats away from its text. */
.checks { display: grid; gap: .55rem; }
.check { display: flex; align-items: center; gap: .55rem; font-size: .89rem; font-weight: 500; cursor: pointer; }
.check input[type="checkbox"] { width: 16px; height: 16px; flex: none; margin: 0; accent-color: var(--accent); }
.check--sm { font-size: .8rem; color: var(--ink-2); }
.actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.err { background: var(--rose-w); color: var(--rose); border: 1px solid color-mix(in srgb, var(--rose) 25%, transparent); padding: .6rem .8rem; border-radius: var(--r); font-size: .88rem; }

/* ---------------------------------------------------------------- detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.1rem; align-items: start; }
.kv { margin: 0; display: grid; grid-template-columns: 132px 1fr; gap: .1rem .8rem; font-size: .9rem; }
.kv dt { color: var(--ink-3); padding: .35rem 0; }
.kv dd { margin: 0; padding: .35rem 0; font-weight: 500; }
.kv dd.gap { color: var(--ink-3); font-weight: 400; }

.timeline { display: grid; gap: .1rem; }
.tl { display: grid; grid-template-columns: 14px 1fr; gap: .7rem; padding: .5rem 0; font-size: .86rem; }
.tl__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin: .4rem 0 0 3px; position: relative; }
.tl__dot::after { content: ""; position: absolute; left: 3.5px; top: 12px; width: 1px; height: calc(100% + .6rem); background: var(--line); }
.tl:last-child .tl__dot::after { display: none; }
.tl b { font-weight: 600; }
.tl time { display: block; font-size: .76rem; color: var(--ink-3); }

.notes { display: grid; gap: .7rem; }
.note { background: #fbfbfd; border: 1px solid var(--line-2); border-radius: var(--r); padding: .6rem .75rem; font-size: .89rem; }
.note header { display: flex; gap: .5rem; font-size: .76rem; color: var(--ink-3); margin-bottom: .25rem; }
.note header b { color: var(--ink-2); }

/* ---------------------------------------------------------------- auth */
.authwrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: radial-gradient(1100px 520px at 50% -10%, #eceafe 0%, var(--paper) 60%); }
.authcard { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-3); padding: 1.6rem; }
.authcard .mark { width: 34px; height: 34px; border-radius: 10px; }
.authcard h1 { font-size: 1.18rem; margin: .8rem 0 .2rem; }
.authcard p.sub { margin: 0 0 1.2rem; color: var(--ink-3); font-size: .9rem; }
.authcard .btn { width: 100%; margin-top: .3rem; }

/* ---------------------------------------------------------------- responsive */
.scrim { position: fixed; inset: 0; background: rgb(16 23 37 / .45); z-index: 40; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 50;
    transform: translateX(-100%); transition: transform .2s cubic-bezier(.16,1,.3,1);
  }
  .rail.open { transform: none; }
  .rail__close { display: block; }
  .burger { display: inline-flex; }
  .detail { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
  .search input { width: 180px; }
}
@media (min-width: 901px) { .scrim { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
