/* Palette and type follow brainbots.lk: deep navy text, airy blue-white paper, BrainBots blue action, Inter + Poppins. */
:root {
  --ink: #1A2C3E; --heading: #0A2B44; --paper: #F8FBFF; --card: #FFFFFF; --line: #E2E8F0;
  --muted: #5A6E80; --action: #1E88E5; --action-hover: #0A5C9E; --action-soft: #EEF5FF; --action-ink: #FFFFFF; --late: #DC2626;
  --shadow: 0 8px 24px rgba(30, 136, 229, 0.08);
  font-family: "Inter", system-ui, sans-serif; font-size: 16px; line-height: 1.5; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); }
main { max-width: 1440px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
h1, h2 { font-family: "Poppins", "Inter", sans-serif; color: var(--heading); }
h1 { font-size: 1.75rem; font-weight: 800; margin: 1rem 0 .75rem; line-height: 1.2; }
h2 { font-size: 1.2rem; font-weight: 700; margin: 1.5rem 0 .5rem; }
a { color: var(--action); }
a:hover { color: var(--action-hover); }
:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; }
.muted { color: var(--muted); font-weight: 400; }
p { margin: .25rem 0; }

/* White sticky bar with the BrainBots colour strip underneath, as on brainbots.lk. */
.top { position: sticky; top: 0; z-index: 100; background: rgba(255, 255, 255, 0.98); backdrop-filter: blur(8px); color: var(--ink);
       box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02), 0 1px 0 #E9F0F5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1.5rem; padding: .6rem 1rem; }
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 3px; background: linear-gradient(90deg, #2196F3, #FF8F00, #388E3C, #7B1FA2); }
.top .brand { display: flex; align-items: center; gap: .6rem; color: var(--heading); font-family: "Poppins", sans-serif; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.top .brand img { height: 44px; width: auto; display: block; mix-blend-mode: multiply; }
.top .brand span { padding-left: .6rem; border-left: 2px solid var(--line); }
.top nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.5rem; }
.top nav a:not(.btn) { color: #1E2F3F; font-weight: 600; font-size: .95rem; text-decoration: none; transition: color .2s; }
.top nav a:not(.btn):hover { color: var(--action); }
.top nav a[aria-current] { color: var(--action); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 8px; }

.btn { display: inline-block; background: var(--action); color: var(--action-ink); border: 2px solid var(--action); border-radius: 50px;
       padding: .45rem 1.2rem; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: all .3s ease; }
.btn:hover { background: var(--action-hover); border-color: var(--action-hover); color: var(--action-ink); transform: translateY(-2px); box-shadow: 0 12px 28px -10px rgba(30, 136, 229, 0.5); }
.btn.ghost { background: transparent; color: var(--action); }
.btn.ghost:hover { background: var(--action-soft); color: var(--action-hover); }
.btn.danger { background: transparent; color: var(--late); border-color: var(--late); }
.btn.danger:hover { background: #FDECEA; color: var(--late); border-color: var(--late); box-shadow: none; }

input, select, textarea { font: inherit; color: inherit; width: 100%; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.15); }
input[readonly] { background: var(--paper); }
label { display: block; font-weight: 600; color: var(--heading); font-size: .92rem; }
label input, label select, label textarea { margin-top: .25rem; font-weight: 400; font-size: 1rem; }
small { display: block; font-weight: 400; margin-top: .2rem; }

.panel { background: var(--card); border: 1px solid rgba(30, 136, 229, 0.15); border-radius: 12px; padding: 1.25rem; box-shadow: var(--shadow); }
.stack { display: grid; gap: .8rem; align-content: start; }
.stack h2 { margin: 0; }
.grid-form { display: grid; gap: .9rem 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-form .wide { grid-column: span 2; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.cols { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.auth { max-width: 380px; margin: 4rem auto; padding: 1.75rem; background: var(--card); border: 1px solid rgba(30, 136, 229, 0.15); border-top: 4px solid var(--action); border-radius: 12px; box-shadow: var(--shadow); }
/* Robot logo in a white circle, brand name under it, on the sign-in and first-account card. */
.auth-brand { text-align: center; margin-bottom: 1rem; }
.auth-logo { display: inline-flex; align-items: center; justify-content: center; width: 112px; height: 112px; border-radius: 50%;
             background: #fff; box-shadow: 0 0 0 8px #E8F5FF, 0 12px 28px -8px rgba(30, 136, 229, 0.35); }
.auth-logo img { height: 72px; width: auto; display: block; }
.auth-name { margin: 1.1rem 0 0; font-family: "Poppins", sans-serif; font-size: 1.5rem; font-weight: 800; color: var(--heading); }
.auth h1 { font-size: 1.25rem; font-weight: 700; text-align: center; margin: .25rem 0 1rem; color: var(--muted); }
.danger { margin-top: 2rem; }

.flash { background: var(--action-soft); border-left: 4px solid var(--action); padding: .6rem .9rem; border-radius: 4px; }
.error { background: #FDECEA; border-left: 4px solid var(--late); padding: .6rem .9rem; border-radius: 4px; color: var(--late); }
.note { background: #FFF6DB; padding: .5rem .8rem; border-radius: 4px; }
.empty { padding: 1.5rem; background: var(--card); border: 1px dashed rgba(30, 136, 229, 0.3); border-radius: 12px; }

.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; vertical-align: middle; white-space: nowrap; }
.s-new { background: #EEF2FF; color: #3730A3; }
.s-contacting { background: #E8F5FF; color: #0A5C9E; }
.s-interested { background: #FFF3DC; color: #9A5B00; }
.s-converted { background: #E3F4E5; color: #2E6E31; }
.s-not_interested { background: #F1F5F9; color: #475569; }
.s-wrong_number { background: #FDE2DF; color: #9A2A1C; }

/* Status counts link straight to the filtered list. */
.counts { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.counts a { display: block; padding: .5rem 1rem; background: linear-gradient(135deg, #F0F6FF 0%, #E1EFFF 100%); border: 1px solid rgba(30, 136, 229, 0.2); border-radius: 12px; text-decoration: none; color: var(--heading); transition: all .3s ease; }
.counts a:hover { transform: translateY(-3px); border-color: rgba(30, 136, 229, 0.4); box-shadow: 0 12px 20px -10px rgba(30, 136, 229, 0.25); color: var(--heading); }
.counts strong { font-family: "Poppins", sans-serif; color: var(--action); font-size: 1.15rem; margin-right: .2rem; }

/* The call queue: the screen staff live in. Large targets for phone use. */
.queue { list-style: none; padding: 0; margin: 0; border: 1px solid rgba(30, 136, 229, 0.15); border-radius: 12px; background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.queue li { display: grid; grid-template-columns: 1fr auto auto; gap: .5rem 1.25rem; align-items: center; padding: .85rem 1rem; border-top: 1px solid var(--line); }
.queue li:first-child { border-top: 0; }
.queue .who > a { color: var(--heading); font-weight: 700; font-size: 1.1rem; }
.queue .last { font-style: italic; color: var(--muted); }
.queue .when { white-space: nowrap; font-weight: 700; }
.queue .when.late { color: var(--late); }
.contact { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters input { flex: 1 1 260px; width: auto; }
.filters select { width: auto; }
.scroll { overflow-x: auto; }
.list { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid rgba(30, 136, 229, 0.15); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.list th, .list td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: .88rem; }
.list th { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--heading); background: #EEF5FF; white-space: nowrap; }
.list tbody tr:hover { background: #F8FAFD; }
.list tr:last-child td { border-bottom: 0; }
.list td[data-label="Reference"], .list td[data-label="Phone"], .list td[data-label="Next"], .list td[data-label="Age / Grade"], .list td[data-label="Status"] { white-space: nowrap; }
.list td[data-label="Reference"] { font-size: .82rem; font-weight: 600; color: var(--muted); }
.list .clip { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; gap: 1rem; justify-content: center; margin-top: 1rem; }

.lead-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; }
.lead-head h1 { margin: .1rem 0 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1.25rem 2rem; margin: 1.25rem 0 2rem; padding: 1.5rem; background: var(--card); border: 1px solid rgba(30, 136, 229, 0.15); border-radius: 12px; box-shadow: var(--shadow); }
.facts > div { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.facts dt { font-size: .85rem; font-weight: 500; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; color: var(--heading); overflow-wrap: break-word; word-break: break-word; }
.timeline { list-style: none; padding: 0 0 0 1rem; margin: 0; border-left: 3px solid #CFE3FC; }
.timeline li { position: relative; padding: 0 0 1rem .5rem; }
.timeline li::before { content: ""; position: absolute; left: -1.45rem; top: .45rem; width: .7rem; height: .7rem; border-radius: 50%; background: var(--action); box-shadow: 0 0 0 3px #E8F5FF; }
.timeline .meta { font-size: .85rem; color: var(--muted); }

@media (max-width: 760px) {
  .cols { grid-template-columns: 1fr; }
  .grid-form .wide { grid-column: auto; }
  .queue li { grid-template-columns: 1fr; }
  .contact .btn { flex: 1; text-align: center; padding: .65rem; }
  .contact > a:not(.btn) { flex-basis: 100%; }

  /* Tables marked .cards become one card per row on phones: label on the left, value on the right. */
  .list.cards, .list.cards tbody, .list.cards tr, .list.cards td { display: block; }
  .list.cards { border: 0; background: none; box-shadow: none; overflow: visible; }
  .list.cards thead { display: none; }
  .list.cards tr { background: var(--card); border: 1px solid rgba(30, 136, 229, 0.15); border-radius: 12px; box-shadow: var(--shadow); padding: .5rem .9rem; margin-bottom: .75rem; }
  .list.cards tbody tr:hover { background: var(--card); }
  .list.cards td { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px solid #F0F4F8; text-align: right; overflow-wrap: anywhere; }
  .list.cards td:last-child { border-bottom: 0; }
  .list.cards td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; text-align: left; flex-shrink: 0; }
  .list.cards td:empty { display: none; }
  .list.cards td.clip { max-width: none; white-space: normal; }
  .list.cards td.card-title { font-size: 1.1rem; font-weight: 700; text-align: left; padding-bottom: .45rem; }
  .list.cards td.card-title::before { display: none; }
  .top .brand img { height: 38px; }
}

/* ---- Password field with show/hide eye ---------------------------------- */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 2.9rem; }
.pw-eye {
  position: absolute; top: 50%; right: .5rem; transform: translateY(-50%);
  width: 2rem; height: 2rem; padding: 0; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.pw-eye:hover { background: var(--action-soft); color: var(--action); }
.pw-eye:focus-visible { outline: 2px solid var(--action); outline-offset: 1px; }
/* Open eye, drawn in CSS so no icon font or external image is needed. */
.pw-eye::before {
  content: ""; width: 1.15rem; height: 1.15rem;
  background: currentColor;
  -webkit-mask: var(--eye) center / contain no-repeat;
          mask: var(--eye) center / contain no-repeat;
}
.pw-eye.on::before { --eye: var(--eye-off); }
:root {
  --eye: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
  --eye-off: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.9 4.24A9.1 9.1 0 0 1 12 4c6.5 0 10 7 10 7a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24'/%3E%3Cpath d='M6.61 6.61A18.4 18.4 0 0 0 2 11s3.5 7 10 7a9.1 9.1 0 0 0 5.39-1.61'/%3E%3Cline x1='2' y1='2' x2='22' y2='22'/%3E%3C/svg%3E");
}

/* ---- Staff page --------------------------------------------------------- */
.btn.small { padding: .35rem .7rem; font-size: .85rem; }
.panel.narrow { max-width: 26rem; }

.stafflist { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.stafflist li {
  background: var(--card); border: 1px solid rgba(30, 136, 229, 0.15);
  border-radius: 12px; box-shadow: var(--shadow); padding: .9rem 1.1rem;
}
.staff-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.staff-name { margin: 0 0 .2rem; font-size: 1.05rem; font-weight: 700; color: var(--heading); }
.staff-top .muted { margin: 0; font-size: .88rem; }
.staff-top .small { font-size: .8rem; margin-top: .25rem; }
.section-title { font-size: .88rem; font-weight: 700; color: var(--heading); margin: 0; border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.badge.r-admin { background: #E8F5FF; color: var(--action-hover); }
.badge.r-staff { background: #F1F5F9; color: var(--muted); }

.rowmenu > summary { display: inline-block; list-style: none; cursor: pointer; }
.rowmenu > summary::-webkit-details-marker { display: none; }

/* The panel sits in normal flow, not absolutely positioned: an ancestor with
   overflow (.scroll, .list) would otherwise clip it and nothing would appear. */
.staff-manage { display: none; }
.stafflist li:has(details[open]) .staff-manage {
  display: grid; gap: 1.1rem; margin-top: .9rem; padding-top: .9rem;
  border-top: 1px solid var(--line);
}
.staff-manage form { margin: 0; }
.staff-manage .btn { justify-self: start; }
.stafflist li.manage-open .staff-manage {
  display: grid; gap: 1.1rem; margin-top: .9rem; padding-top: .9rem;
  border-top: 1px solid var(--line);
}
