/* =====================================================================
   LEAD PANEL — design system
   Dark, cohesive gray palette. Left sidebar -> bottom bar on narrow.
   One set of tokens drives every page so nothing clashes.
   ===================================================================== */

:root {
  /* Surfaces: layered grays, darkest at the back */
  --bg-0:  #14161a;   /* app background            */
  --bg-1:  #1b1e24;   /* sidebar / cards           */
  --bg-2:  #22262e;   /* raised rows / inputs      */
  --bg-3:  #2b303a;   /* hover / active            */
  --line:  #343a45;   /* borders / dividers        */

  /* Text */
  --tx-1:  #e8eaed;   /* primary text              */
  --tx-2:  #aab0bb;   /* secondary                 */
  --tx-3:  #727886;   /* muted / placeholder       */

  /* Accent (calm steel blue — the one non-gray) */
  --ac:    #5b8def;
  --ac-dim:#3a5da8;
  --ac-bg: rgba(91,141,239,.12);

  /* Status / labels — distinct but muted to sit well on gray */
  --cb:     #d9a441;  /* Call back     amber  */
  --dpu:    #8a93a3;  /* Didn't pick up slate */
  --vm:     #7e6cf0;  /* Voicemail     violet */
  --dead:   #c65b5b;  /* Dead          red    */
  --finish: #46b17b;  /* Finished/sale green  */

  --ok:    #46b17b;
  --warn:  #d9a441;
  --err:   #c65b5b;

  --radius: 9px;
  --radius-sm: 6px;
  --shadow: 0 2px 10px rgba(0,0,0,.35);
  --sidebar-w: 224px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--tx-1);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ac); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { font-weight: 600; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; color: var(--tx-2); }
small { color: var(--tx-3); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  padding: 18px 18px 14px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .02em;
  color: var(--tx-1);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 9px;
}
.brand-ico { color: var(--ac); flex: 0 0 auto; display: inline-flex; }

/* nav is the positioning context for the sliding indicator */
.nav { padding: 10px 10px; flex: 1; overflow-y: auto; position: relative; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; margin: 2px 0;
  border-radius: var(--radius-sm);
  color: var(--tx-2);
  font-weight: 500;
  position: relative; z-index: 1;
}
.nav a:hover { background: var(--bg-2); color: var(--tx-1); text-decoration: none; }
.nav a.active { background: var(--bg-2); color: var(--tx-1); }

/* The square right-edge indicator that slides between active items */
.nav-ind {
  position: absolute;
  right: 0; top: 0; width: 3px; height: 0;
  background: var(--ac);
  border-radius: 0;            /* square, as requested */
  opacity: 0;
  z-index: 2;
  transition: top .28s cubic-bezier(.4, 0, .2, 1),
              height .28s cubic-bezier(.4, 0, .2, 1);
}
.nav-ind.show { opacity: 1; }
/* Fallback when JS is off: static square right border on the active item */
.no-js .nav a.active { box-shadow: inset -3px 0 0 var(--ac); }
.nav a .ico { width: 18px; display: inline-flex; align-items: center; justify-content: center; opacity: .9; }
.nav .group-label { padding: 14px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--tx-3); }
.nav a .badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--err); color: #fff;
  font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}

.sidebar .foot {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  font-size: 12px; color: var(--tx-3);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; flex: 0 0 56px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-0);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-weight: 600; font-size: 15px; }
.topbar .spacer { flex: 1; }
.content { padding: 20px; flex: 1; }
.container { max-width: 1260px; margin: 0 auto; }

/* ---------- Cards / tiles ---------- */
.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card .card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card .card-h h2 { margin: 0; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.tile {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
}
.tile .label { font-size: 12px; color: var(--tx-3); text-transform: uppercase; letter-spacing: .05em; }
.tile .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.tile .sub { font-size: 12px; color: var(--tx-2); margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--tx-1);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); text-decoration: none; }
.btn.primary { background: var(--ac); border-color: var(--ac); color: #fff; }
.btn.primary:hover { background: #4f7fe0; }
.btn.danger { background: transparent; border-color: var(--dead); color: var(--dead); }
.btn.danger:hover { background: rgba(198,91,91,.12); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label.fld { display: block; margin-bottom: 13px; }
label.fld .lab { display: block; font-size: 12px; color: var(--tx-2); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=time],
input[type=email], select, textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--tx-1);
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ac); box-shadow: 0 0 0 3px var(--ac-bg);
}
::placeholder { color: var(--tx-3); }
.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline label.fld { margin-bottom: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th {
  background: var(--bg-2); color: var(--tx-2); font-weight: 600;
  position: sticky; top: 0; cursor: pointer; user-select: none;
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
}
table.data th.nosort { cursor: default; }
table.data th .arrow { opacity: .5; font-size: 10px; margin-left: 4px; }
table.data tbody tr:hover { background: var(--bg-2); }
table.data tbody tr.sel { background: var(--ac-bg); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--tx-3); }

/* Pinned first column(s): checkbox + name stay visible while scrolling right */
table.data th.sticky-col, table.data td.sticky-col {
  position: sticky; left: 0; z-index: 3; background: var(--bg-1);
}
table.data th.sticky-col { background: var(--bg-2); z-index: 4; }
table.data th.sticky-col2, table.data td.sticky-col2 {
  position: sticky; left: 42px; z-index: 3; background: var(--bg-1);
  box-shadow: 6px 0 8px -6px rgba(0,0,0,.55);   /* edge shadow */
}
table.data th.sticky-col2 { background: var(--bg-2); z-index: 4; }
table.data tbody tr:hover td.sticky-col,
table.data tbody tr:hover td.sticky-col2 { background: var(--bg-2); }
table.data tbody tr.sel td.sticky-col,
table.data tbody tr.sel td.sticky-col2 { background: #202b3e; }
/* when no checkbox column (agent view), name pins at the far left */
table.data td.sticky-col2:first-child, table.data th.sticky-col2:first-child { left: 0; }

/* ---------- Label pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  border: 1px solid transparent;
}
.pill svg { width: 13px; height: 13px; }

/* inline SVG icons inherit colour + align to text */
.ico-svg { display: inline-block; vertical-align: -0.15em; flex: 0 0 auto; }
.btn .ico-svg { vertical-align: middle; }
.pill.cb     { color: var(--cb);     background: rgba(217,164,65,.12);  border-color: rgba(217,164,65,.3); }
.pill.dpu    { color: var(--dpu);    background: rgba(138,147,163,.12); border-color: rgba(138,147,163,.3); }
.pill.vm     { color: var(--vm);     background: rgba(126,108,240,.12); border-color: rgba(126,108,240,.3); }
.pill.dead   { color: var(--dead);   background: rgba(198,91,91,.12);   border-color: rgba(198,91,91,.3); }
.pill.finish { color: var(--finish); background: rgba(70,177,123,.12);  border-color: rgba(70,177,123,.3); }
.pill.none   { color: var(--tx-3);   background: var(--bg-2);           border-color: var(--line); }

/* label picker (dropdown of pills) */
.label-pick { position: relative; display: inline-block; }
.label-menu {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 6px; display: none; min-width: 150px;
}
.label-menu.open { display: block; }
.label-menu button {
  display: flex; width: 100%; align-items: center; gap: 8px;
  background: none; border: none; color: var(--tx-1); padding: 6px 8px;
  border-radius: 5px; cursor: pointer; font-size: 13px; text-align: left;
}
.label-menu button:hover { background: var(--bg-2); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 620px; max-height: 86vh; overflow: auto;
}
.modal .m-h { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-1); }
.modal .m-h h2 { margin: 0; }
.modal .m-h .x { margin-left: auto; cursor: pointer; color: var(--tx-3); font-size: 20px; line-height: 1; background: none; border: none; }
.modal .m-b { padding: 18px; }
.modal .m-f { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--bg-1); }

/* key/value grid in the overview modal */
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.kv .k { background: var(--bg-2); padding: 8px 12px; color: var(--tx-2); font-size: 12px; }
.kv .v { background: var(--bg-1); padding: 8px 12px; font-size: 13px; word-break: break-word; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px; border: 1px solid; }
.alert.err  { background: rgba(198,91,91,.1);  border-color: rgba(198,91,91,.4);  color: #f0b4b4; }
.alert.ok   { background: rgba(70,177,123,.1); border-color: rgba(70,177,123,.4); color: #a7e0c4; }
.alert.warn { background: rgba(217,164,65,.1); border-color: rgba(217,164,65,.4); color: #e8cf98; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 360px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 24px; box-shadow: var(--shadow); }
.auth-card .brand { font-weight: 700; font-size: 17px; margin-bottom: 4px; display: flex; align-items: center; gap: 9px; }
.auth-card .sub { color: var(--tx-3); font-size: 13px; margin-bottom: 20px; }

/* Repeating "calling" pattern behind the auth/closed pages.
   A tiled phone handset glyph, a touch lighter than the base bg. */
.auth-wrap {
  background-color: var(--bg-0);
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%2292%22%20height=%2292%22%20viewBox=%220%200%2092%2092%22%3E%3Cg%20fill=%22none%22%20stroke=%22%232e3c58%22%20stroke-width=%222%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%20transform=%22translate(24%2024)%20scale(1.75)%22%3E%3Cpath%20d=%22M15.05%205A5%205%200%200%201%2019%208.95M15.05%201A9%209%200%200%201%2023%208.94m-1%207.98v3a2%202%200%200%201-2.18%202%2019.79%2019.79%200%200%201-8.63-3.07%2019.5%2019.5%200%200%201-6-6%2019.79%2019.79%200%200%201-3.07-8.67A2%202%200%200%201%204.11%202h3a2%202%200%200%201%202%201.72c.13.96.36%201.9.7%202.81a2%202%200%200%201-.45%202.11L8.09%209.91a16%2016%200%200%200%206%206l1.27-1.27a2%202%200%200%201%202.11-.45c.91.34%201.85.57%202.81.7A2%202%200%200%201%2022%2016.92z%22/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* password strength meter */
.pw-meter { height: 6px; border-radius: 3px; background: var(--bg-3); overflow: hidden; margin-top: 7px; }
.pw-meter > span { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.pw-reqs { list-style: none; padding: 0; margin: 8px 0 0; font-size: 12px; }
.pw-reqs li { color: var(--tx-3); padding: 1px 0; }
.pw-reqs li.met { color: var(--ok); }
.pw-reqs li::before { content: "○ "; }
.pw-reqs li.met::before { content: "● "; }

/* ---------- Misc ---------- */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 20px; background: var(--bg-2); border: 1px solid var(--line); color: var(--tx-2); }
.tz-dual { font-size: 11px; color: var(--tx-3); }
.tz-dual b { color: var(--tx-2); font-weight: 600; }
.hidden { display: none !important; }
.flex { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }

/* ---------- Responsive: sidebar -> bottom bar ---------- */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; height: 58px; flex-direction: row; z-index: 50;
    border-right: none; border-top: 1px solid var(--line);
  }
  .sidebar .brand, .sidebar .foot, .nav .group-label { display: none; }
  .nav { display: flex; padding: 0; overflow-x: auto; width: 100%; }
  .nav-ind { display: none; }                      /* no slide on bottom bar */
  .nav a { flex-direction: column; gap: 2px; font-size: 10px; padding: 8px 12px; margin: 0; flex: 1; justify-content: center; }
  .nav a.active { box-shadow: inset 0 3px 0 var(--ac); }  /* top border on mobile */
  .nav a .ico { font-size: 18px; }
  .nav a .txt { white-space: nowrap; }
  .nav a .badge { position: absolute; margin: 0; transform: translate(10px,-8px); }
  .main { padding-bottom: 58px; }
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}
