/*
 * The H4 Marketing Group design language, taken from h4marketinggroup.com:
 * white and warm white, black type, gold accents, soft shadows, Inter.
 * Light only, like the site. Greens, reds and amber are kept for what they
 * mean (live, blocked, warning) rather than for decoration.
 */
:root {
  color-scheme: light;
  --black: #000000;
  --button-black: #070707;
  --white: #ffffff;
  --warm-white: #faf7f1;
  --gold: #c79a45;
  --gold-deep: #b8862b;
  --gold-soft: #d7b56d;
  --line: #e5e1d8;
  --line-soft: #efeae1;

  --bg: var(--warm-white);
  --card: var(--white);
  --text: #111111;
  --muted: #5f5b55;
  --border: var(--line);
  --primary: var(--button-black);
  --primary-ink: var(--white);
  --accent: var(--gold);
  --accent-deep: var(--gold-deep);
  --green: #18794e;
  --green-bg: #e8f5ee;
  --red: #c2341d;
  --amber: #b45309;
  --radius: 14px;
  --shadow-card: 0 25px 70px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.04);
  --shadow-button: 0 12px 30px rgba(0, 0, 0, 0.14);
}

* { box-sizing: border-box; }

/*
 * The HTML `hidden` attribute works only through the browser default
 * `[hidden] { display: none }`, which ANY author rule setting `display` beats.
 * `.overlay` and `.centered` both set display, so hidden elements carrying them
 * stayed on screen. Enforce it once here rather than per-class, so adding a
 * display-setting class to a toggled element can never resurrect this.
 */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% 6%, rgba(250, 247, 241, 0.95), rgba(255, 255, 255, 0) 34%),
    linear-gradient(135deg, var(--white) 0%, var(--white) 56%, var(--warm-white) 100%);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--accent-deep); }
a:hover { color: var(--black); }

h1 { font-size: 22px; font-weight: 800; letter-spacing: 0; margin: 0 0 4px; color: var(--black); }
/* Card titles are the site's "kicker": small, gold, spaced capitals. */
h2 { font-size: 12.5px; margin: 0 0 14px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; color: var(--accent-deep); }
h3 { font-size: 12px; margin: 20px 0 8px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); font-size: 13px; margin: 8px 0 0; }
.ok { color: var(--green); font-size: 13px; margin: 8px 0 0; }
/* A standing message inside a sheet: what has to happen before the sheet can close. */
.notice { border-left: 3px solid var(--amber); padding: 8px 12px; margin: 0 0 12px; background: color-mix(in srgb, var(--amber) 8%, transparent); }

.centered { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-soft);
}
.card.narrow { width: 100%; max-width: 380px; padding: 30px; border-radius: 18px; box-shadow: var(--shadow-card); }

/* The brand mark: logo plus name, as on the website header. */
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--black); text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand img { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; }
.brand .product { color: var(--muted); font-weight: 500; }
.brand .product::before { content: '·'; margin: 0 8px 0 2px; color: var(--line); }
.card.narrow .brand { margin-bottom: 18px; }
.card.narrow .brand img { width: 56px; height: 56px; }
.card.dimmed { opacity: .5; }

label { display: block; margin: 12px 0; font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=email], input[type=password], input[type=tel], input[type=text] {
  width: 100%; margin-top: 6px; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--white); color: var(--text); font: inherit; font-size: 15px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-soft); outline-offset: 1px; border-color: var(--gold); }

button { font: inherit; font-weight: 700; cursor: pointer; border-radius: 8px; padding: 11px 18px; border: 1px solid transparent; transition: background .15s, color .15s, box-shadow .15s, transform .15s; }
button.primary { background: var(--primary); color: var(--primary-ink); width: 100%; box-shadow: var(--shadow-button); }
button.primary:hover { transform: translateY(-1px); }
button.primary:disabled { opacity: .55; transform: none; cursor: default; }
button.danger  { background: var(--red); color: #fff; }
button.ghost   { background: var(--white); color: var(--black); border-color: var(--border); }
button.ghost:hover { border-color: var(--gold); color: var(--accent-deep); }
button.small-btn { padding: 6px 12px; font-size: 13px; font-weight: 600; }

/* Sticky header in the website's style: translucent white, blur, hairline. */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  min-height: 72px; padding: 12px clamp(16px, 3vw, 32px);
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(229, 225, 216, 0.8);
}
.topbar .who-wrap { display: flex; flex-direction: column; line-height: 1.25; margin-right: auto; }
.topbar .who-wrap .muted { font-size: 13px; }
@media (max-width: 640px) {
  .brand span:not(.product) { display: none; }
  .brand .product::before { content: none; }
}

.grid {
  display: grid; gap: 16px; padding: 20px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  max-width: 1200px; margin: 0 auto;
}
.wide { grid-column: 1 / -1; }

/* Availability toggle */
.status-button {
  width: 100%; display: flex; align-items: center; gap: 10px; justify-content: center;
  padding: 18px; font-size: 17px; font-weight: 700; border-radius: 10px;
  border: 1px solid var(--border); background: var(--warm-white); color: var(--text);
}
.status-button:hover { border-color: var(--gold); }
.status-button.available { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.status-button .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status-button.available .dot { background: var(--green); }

.modes { display: grid; gap: 8px; }
.mode {
  display: flex; gap: 10px; align-items: flex-start; margin: 0;
  padding: 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.mode:has(input:checked) { border-color: var(--gold); background: rgba(199, 154, 69, 0.06); }
.mode input { accent-color: var(--gold-deep); }
.mode input { margin-top: 3px; }
.mode div { display: flex; flex-direction: column; gap: 2px; }
.mode strong { color: var(--text); font-size: 14px; }

#cell-row { display: flex; gap: 8px; align-items: flex-end; }
#cell-row label { flex: 1; }

/* Softphone */
.phone-state { font-weight: 600; margin: 0 0 12px; }
.incoming-from { font-size: 16px; margin: 0 0 12px; }
.timer { font-size: 28px; font-variant-numeric: tabular-nums; margin: 0 0 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row button { flex: 1; }
/* Inputs in a flex row need an explicit grow, or a sibling button squashes
   them to nothing. min-width:0 stops the default min-content floor. */
.row input { flex: 1; min-width: 0; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: 0; }
.list .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.list .dot.available { background: var(--green); }
.list .dot.busy { background: var(--amber); }
.list .dot.offline { background: var(--muted); }

.badge {
  display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 12px; text-align: center;
}
.badge:empty { display: none; }

/* Calls table */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border);
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
td { padding: 10px 6px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }

.pill { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--white); border: 1px solid var(--border); }
.pill.answered  { color: var(--green); border-color: var(--green); }
.pill.voicemail { color: var(--amber); border-color: var(--amber); }
.pill.no_agents { color: var(--red);   border-color: var(--red); }

@media (max-width: 520px) {
  .grid { padding: 12px; }
  #cell-row { flex-direction: column; align-items: stretch; }
}

/* Licensed states picker */
.state-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 2px; max-height: 240px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin: 10px 0;
}
.state-grid label {
  display: flex; align-items: center; gap: 6px; margin: 0;
  padding: 4px 6px; border-radius: 6px; font-size: 13px; color: var(--text); cursor: pointer;
}
.state-grid label:hover { background: var(--warm-white); }
.state-grid input, .mode-dispute input, label input[type=checkbox] { accent-color: var(--gold-deep); }
.state-grid input { margin: 0; }
input[type=search] {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--white); color: var(--text); font: inherit; font-size: 14px;
}
.state-tag {
  display: inline-block; padding: 1px 6px; margin-left: 4px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border); font-size: 11px;
}

/* Transcript viewer */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: grid; place-items: center; padding: 16px; z-index: 50;
}
.sheet {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: 18px; box-shadow: var(--shadow-card);
  width: 100%; max-width: 680px; max-height: 80vh; display: flex; flex-direction: column;
}
.sheet-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.sheet-body { padding: 16px 20px; overflow-y: auto; }

.turn { display: flex; gap: 10px; padding: 8px 0; }
.turn .who {
  flex: 0 0 64px; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; padding-top: 2px;
}
.turn.caller .who { color: var(--accent-deep); }
.turn.agent  .who { color: var(--green); }
.turn.unknown .who { color: var(--muted); }
.turn .what { flex: 1; }
.turn .at { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--warm-white); }
.has-transcript { color: var(--green); font-size: 12px; }
#search-results mark { background: transparent; color: var(--accent-deep); font-weight: 700; }

/* Lead marketplace */
.lead-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px;
}
.lead-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.lead-card .st { font-size: 15px; font-weight: 600; }
.lead-card .age { color: var(--muted); font-size: 12px; }
.lead-card .price { font-size: 19px; font-weight: 800; color: var(--black); }
.lead-card:hover { border-color: var(--gold-soft); }
.includes { margin: 6px 0; padding-left: 18px; font-size: 13px; }
.includes li { padding: 1px 0; }
.buy-price { font-size: 20px; font-weight: 600; margin: 14px 0; }
.lead-row { display: flex; flex-direction: column; gap: 2px; }
.row-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.row-actions .state-in {
  width: 48px; padding: 6px 8px; text-align: center; text-transform: uppercase;
}
.lead-row .ph { font-size: 15px; font-weight: 600; }
.fresh-badge {
  display: inline-block; padding: 1px 6px; border-radius: 6px; font-size: 11px;
  background: var(--green-bg); color: var(--green); border: 1px solid var(--green);
}

/* Admin inventory */
.stats { display: flex; flex-wrap: wrap; gap: 20px; margin: 0 0 16px; }
.stat .n { font-size: 22px; font-weight: 600; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.pill.sold      { color: var(--muted); }
.pill.available { color: var(--green); border-color: var(--green); }
.pill.pending   { color: var(--amber); border-color: var(--amber); }
.contains { color: var(--muted); font-size: 12px; }

/* Account card: shown only when it has something to say. */
.account-card.blocked { border-color: var(--red); }
.account-card.blocked #account-status { color: var(--red); font-weight: 600; }
.account-card #account-status { margin: 0 0 6px; }

/* Agents table (admin) */
#agents-table select, #agents-table input[type=date] {
  font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--card, #fff); color: var(--text);
}
#agents-table .pill.locked   { color: var(--red);   border-color: var(--red); }
#agents-table .pill.unlocked { color: var(--green); border-color: var(--green); }
#agents-table .pill.expired  { color: var(--amber); border-color: var(--amber); }
#agents-table td.who strong { display: block; }
#agents-table td.who .muted { font-size: 12px; }
#agents-table .warn { color: var(--amber); }
#agents-table .pill { white-space: nowrap; }

/* Money */
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 90px; }
.stat strong { font-size: 18px; }
.billing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.billing-grid h3:first-child { margin-top: 0; }
.billing-grid input[type=number], #ms-spend, #tu-amount, #tu-note, #tu-kind, #cr-amount {
  width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card, #fff); color: var(--text); box-sizing: border-box;
}
#agents-table input[type=number] { width: 80px; font: inherit; font-size: 13px; padding: 4px 6px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--card, #fff); color: var(--text); }
#st-table td.amt, #st-table th.amt { text-align: right; font-variant-numeric: tabular-nums; }
#st-table td.amt.neg { color: var(--red); }
#st-table td.amt.pos { color: var(--green); }
.balance-low { color: var(--red); font-weight: 600; }
@media (max-width: 720px) { .billing-grid { grid-template-columns: 1fr; } }

/* A button that sits beside inputs in a .row and keeps its natural width. */
.row > button.fit { flex: 0 0 auto; width: auto; }

/* Wide admin tables scroll inside their card rather than clipping. */
#agents-card, #billing-card, #inventory-card, #recallers-card { overflow-x: auto; }

/* Profile menu */
.menu-wrap { position: relative; }
.me-btn { display: inline-flex; align-items: center; gap: 8px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; background: var(--bg); }
.avatar.big { width: 72px; height: 72px; font-size: 28px; display: grid; place-items: center; color: var(--muted); }
.avatar.empty { border: 1px dashed var(--border); }
.avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.file-btn { display: inline-block; cursor: pointer; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; font-size: 13px; margin-right: 6px; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--line-soft);
  border-radius: 12px; box-shadow: var(--shadow-card); min-width: 170px; z-index: 40; padding: 6px; }
.menu-item { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 10px 12px; border-radius: 6px; }
.menu-item:hover { background: var(--warm-white); }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.profile-grid input[type=text], .profile-grid input[type=tel], .profile-grid input[type=email], .profile-grid select {
  width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card, #fff); color: var(--text); box-sizing: border-box;
}
.profile-grid .row label { flex: 1; }
.dispo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
#dispo-overlay input[type=number], #dispo-overlay input[type=text], #dispo-overlay input[type=datetime-local] {
  width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card, #fff); color: var(--text); box-sizing: border-box;
}
#dispo-overlay .row label { flex: 1; }
.lead-details { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.lead-audio { width: 100%; margin-top: 6px; }
.calls-player { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.calls-player audio { flex: 1; min-width: 240px; }
@media (max-width: 720px) { .profile-grid, .dispo-grid { grid-template-columns: 1fr; } }

/* Show / hide password */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 56px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; padding: 4px 8px; font-size: 12px;
  color: var(--accent-deep); cursor: pointer; border-radius: 6px;
}
.pw-toggle:hover { background: var(--warm-white); }

/* Disputes */
.mode-dispute { grid-column: 1 / -1; border-style: dashed; }
#dispo-reason { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card, #fff); color: var(--text); }
#disputes-table td { vertical-align: top; }
#disputes-table .pill.open { color: var(--amber); border-color: var(--amber); }
#disputes-table .pill.refunded { color: var(--green); border-color: var(--green); }
#disputes-table .pill.rejected { color: var(--red); border-color: var(--red); }
#disputes-table .note { max-width: 220px; font-size: 13px; }
#disputes-table .decide { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
#disputes-table .decide input { font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; width: 100%; box-sizing: border-box; }
#disputes-card { overflow-x: auto; }
.dispute-audio { width: 240px; margin-top: 4px; }

/* ---------------- Lead-type tabs ---------------- */
.tabs {
  position: sticky; top: 72px; z-index: 25;
  display: flex; gap: 4px; padding: 0 clamp(16px, 3vw, 32px);
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line-soft); overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  padding: 14px 14px 12px; font-size: 14px; font-weight: 700; color: var(--muted); white-space: nowrap;
}
.tab:hover { color: var(--black); }
.tab.active { color: var(--black); border-bottom-color: var(--gold); }

/* ---------------- The lead sheet ---------------- */
.sheet-toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.sheet-toolbar h2 { margin-bottom: 6px; }
.sheet-actions { flex-wrap: wrap; }
.sheet-agent { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.sheet-agent select { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--white); color: var(--text); }
.button-link { display: inline-flex; align-items: center; text-decoration: none; color: var(--black); border: 1px solid var(--border); background: var(--white); border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
.button-link:hover { border-color: var(--gold); color: var(--accent-deep); }
.sheet-scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--line-soft); border-radius: 10px; }
#sheet-table { font-size: 13px; min-width: 100%; }
#sheet-table th { position: sticky; top: 0; background: var(--white); white-space: nowrap; z-index: 1; }
#sheet-table td { white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
#sheet-table td.hl-cell { width: 1%; }
#sheet-table select.hl {
  font: inherit; font-size: 12px; padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--white); color: var(--text);
}
tr.hl-yellow td { background: #fff6c2; }
tr.hl-green  td { background: #dff5e3; }
tr.hl-blue   td { background: #dceaff; }
tr.hl-pink   td { background: #ffe0ec; }
tr.hl-orange td { background: #ffe4c7; }
tr.hl-grey   td { background: #ebebeb; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; margin-right: 4px; vertical-align: middle; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
#sources-list li { flex-direction: column; align-items: stretch; gap: 4px; }
#sources-list code { display: block; font-size: 12px; word-break: break-all; background: var(--warm-white); padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line-soft); }
#up-type, #up-agent { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--white); color: var(--text); }
