/* =========================================================
   Zenra System Console — extends styles.css
   ========================================================= */

.admin {
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ok: #9fcf99;
  --warn: #e6c27a;
  --danger: #e09a8f;
  background:
    radial-gradient(60% 40% at 100% 0%, rgba(201, 169, 110, 0.07), transparent 70%),
    radial-gradient(50% 40% at 0% 100%, rgba(201, 169, 110, 0.05), transparent 70%),
    var(--bg);
  min-height: 100vh;
}

/* Subtle marble-like grain */
.admin::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(201, 169, 110, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201, 169, 110, 0.035) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
  z-index: 0;
}

/* ---------- Lock state ---------- */
.admin.is-locked .console-bar,
.admin.is-locked .console {
  filter: blur(14px);
  pointer-events: none;
  user-select: none;
}
.admin:not(.is-locked) .gate { display: none; }
.gate .modal__backdrop { background: rgba(6, 5, 4, 0.6); }
.gate__back {
  display: inline-block;
  margin-top: 20px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--muted);
  transition: color 0.3s;
}
.gate__back:hover { color: var(--gold-light); }

/* ---------- Buttons ---------- */
.btn--danger {
  border-color: rgba(224, 154, 143, 0.45);
  color: var(--danger);
  background: rgba(224, 154, 143, 0.06);
}
.btn--danger:hover { border-color: var(--danger); background: rgba(224, 154, 143, 0.14); }
button.btn--ghost { font-family: var(--sans); }

/* ---------- Top bar ---------- */
.console-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(20px, 3vw, 44px);
  background: rgba(11, 9, 7, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.console-bar__brand { display: flex; align-items: center; gap: 12px; }
.console-bar__name { font-family: var(--serif); font-size: 20px; font-weight: 600; letter-spacing: 0.3em; }
.console-bar__divider { width: 1px; height: 22px; background: var(--line-strong); }
.console-bar__label {
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}
.console-bar__right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; margin-right: 8px; }
.clock strong { font-family: var(--mono); font-weight: 500; font-size: 15px; letter-spacing: 0.06em; color: var(--text); }
.clock span { font-family: var(--mono); font-size: 10.5px; color: var(--dim); letter-spacing: 0.08em; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-light);
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }

/* ---------- Layout ---------- */
.console {
  position: relative;
  z-index: 1;
  width: min(100% - 40px, 1440px);
  margin: 0 auto;
  padding: 44px 0 80px;
  display: grid;
  gap: 24px;
}
.console__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 8px;
}
.console__head .eyebrow { margin-bottom: 10px; }
.console__head h1 { font-family: var(--serif); font-size: clamp(34px, 4vw, 52px); line-height: 1.05; }
.console__sync { margin: 0; font-family: var(--mono); font-size: 11px; color: var(--dim); letter-spacing: 0.08em; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.kpi {
  position: relative;
  padding: 26px 24px 22px;
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute; top: 0; left: 24px;
  width: 36px; height: 2px;
  background: var(--gold);
}
.kpi::after {
  content: "";
  position: absolute; right: 12px; bottom: 12px;
  width: 14px; height: 14px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}
.kpi__num {
  display: block;
  font-family: var(--serif);
  font-size: 54px;
  font-weight: 500;
  line-height: 1;
  color: var(--gold-light);
}
.kpi__label {
  display: block;
  margin-top: 14px;
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Panels ---------- */
.insights { display: grid; grid-template-columns: 1fr 1.25fr; gap: 24px; }
.panel {
  position: relative;
  padding: clamp(22px, 2.4vw, 32px);
  background: linear-gradient(170deg, rgba(30, 25, 20, 0.92), rgba(17, 14, 11, 0.94));
  border: 1px solid var(--line);
  border-radius: 14px;
  min-width: 0;
}
.panel::before {
  content: "";
  position: absolute; top: -1px; left: -1px;
  width: 22px; height: 22px;
  border-top: 1px solid var(--gold);
  border-left: 1px solid var(--gold);
  border-top-left-radius: 14px;
}
.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.panel__head--wrap { flex-wrap: wrap; align-items: center; }
.panel__head h2 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 500;
}
.panel__head h2 span {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-left: 6px;
}
.panel__head small { font-family: var(--mono); font-size: 11px; color: var(--dim); letter-spacing: 0.06em; white-space: nowrap; }
.panel__foot {
  margin: 20px 0 0;
  font-size: 11.5px;
  color: var(--dim);
  letter-spacing: 0.04em;
}
.panel__foot code { font-family: var(--mono); color: var(--gold); }

/* Agent demand bars */
.demand { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.demand li { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 6px 14px; align-items: center; }
.demand__name { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demand__count { grid-row: span 2; text-align: right; font-family: var(--mono); font-size: 13px; color: var(--gold-light); }
.demand__bar { height: 4px; background: rgba(242, 235, 223, 0.06); border-radius: 4px; overflow: hidden; }
.demand__bar span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-light));
  border-radius: 4px;
  transition: width 0.9s var(--ease);
}
.demand li.is-zero .demand__name, .demand li.is-zero .demand__count { color: var(--dim); }

/* ---------- Tables ---------- */
.table-wrap {
  position: relative;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 169, 110, 0.35) transparent;
}
.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-track { background: rgba(242, 235, 223, 0.04); border-radius: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: rgba(201, 169, 110, 0.35); border-radius: 6px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: var(--gold); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  padding: 0 14px 14px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 16px 14px;
  border-bottom: 1px solid rgba(201, 169, 110, 0.08);
  vertical-align: middle;
}
.table th:first-child, .table td:first-child { padding-left: 0; }
.table .num { text-align: right; font-family: var(--mono); }
.table--geo td:first-child { font-family: var(--mono); color: var(--dim); width: 36px; }
.geo__country { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.geo__flag { font-size: 18px; line-height: 1; }
.geo__code { font-family: var(--mono); font-size: 10px; color: var(--dim); }
.gauge { width: 100%; min-width: 120px; height: 4px; background: rgba(242, 235, 223, 0.06); border-radius: 4px; overflow: hidden; }
.gauge span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-deep), var(--gold-light)); }
.share { color: var(--gold-light); }
.table__empty td { padding: 40px 0; text-align: center; color: var(--dim); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }

/* Leads */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; }
.filters { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.search {
  flex: 1 1 320px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(11, 9, 7, 0.5);
  transition: border-color 0.3s;
}
.search:focus-within { border-color: var(--gold); }
.search svg { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: var(--gold); stroke-width: 1.6; stroke-linecap: round; }
.search input {
  flex: 1;
  min-width: 0;
  padding: 12px 0;
  background: none; border: 0; outline: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
}
.search input::placeholder { color: var(--dim); }
.select--compact select {
  appearance: none;
  -webkit-appearance: none;
  min-width: 170px;
  padding: 12px 40px 12px 18px;
  background: rgba(11, 9, 7, 0.5);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
.select--compact select:focus { border-color: var(--gold); }
.select--compact select option { background: #17130f; }
.select--compact::after { right: 18px; }

.table--leads { min-width: 1180px; }
.table--leads tbody tr { cursor: pointer; transition: background 0.25s; }
.table--leads tbody tr:hover { background: rgba(201, 169, 110, 0.05); }
.table--leads td { color: var(--muted); }
.cell-time { font-family: var(--mono); font-size: 11.5px; white-space: nowrap; color: var(--dim); }
.cell-time b { display: block; font-weight: 500; color: var(--text); font-size: 12px; }
.cell-name { color: var(--text) !important; font-weight: 500; white-space: nowrap; }
.cell-name .tag { margin-left: 8px; }
.cell-email, .cell-phone { white-space: nowrap; }
.cell-company { color: var(--text) !important; }
.cell-agent { white-space: nowrap; color: var(--gold-light) !important; font-size: 12.5px; }
.cell-problem { max-width: 320px; }
.cell-problem p {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
}
.cell-actions { text-align: right; white-space: nowrap; }
.icon-btn {
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s;
}
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { border-color: var(--line-strong); }
.icon-btn--danger:hover { border-color: rgba(224, 154, 143, 0.5); background: rgba(224, 154, 143, 0.08); }
.icon-btn--danger:hover svg { stroke: var(--danger); }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid currentColor;
}
.tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.tag--new { color: var(--gold-light); }
.tag--contacted { color: #9ec3e6; }
.tag--qualified { color: var(--ok); }
.tag--closed { color: var(--dim); }
.tag--sample { color: var(--dim); border-style: dashed; font-size: 9px; padding: 2px 8px; }
.tag--sample::before { display: none; }

.empty { display: none; padding: 64px 20px; text-align: center; }
.empty.is-visible { display: block; }
.empty__mark { display: block; font-size: 28px; color: var(--gold); margin-bottom: 14px; }
.empty p { margin: 0; font-family: var(--serif); font-size: 22px; color: var(--text); }
.empty small { display: block; margin-top: 8px; font-size: 12.5px; color: var(--dim); }

/* ---------- Drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 150; pointer-events: none; }
.drawer__backdrop {
  position: absolute; inset: 0;
  background: rgba(6, 5, 4, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}
.drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(100%, 520px);
  padding: 56px clamp(24px, 3vw, 44px) 40px;
  overflow-y: auto;
  background: linear-gradient(170deg, #1f1a14, #100d0a);
  border-left: 1px solid var(--line-strong);
  transform: translateX(100%);
  transition: transform 0.5s var(--ease);
}
.drawer.is-open { pointer-events: auto; }
.drawer.is-open .drawer__backdrop { opacity: 1; }
.drawer.is-open .drawer__panel { transform: none; }
.drawer .modal__close { top: 20px; right: 20px; }
.drawer h2 { font-family: var(--serif); font-size: 38px; line-height: 1.1; }
.drawer__company { margin: 6px 0 30px; font-family: var(--serif); font-style: italic; font-size: 20px; color: var(--gold-light); }
.drawer__meta { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 22px 24px; padding: 24px 0; border-block: 1px solid var(--line); }
.drawer__meta div { min-width: 0; }
.drawer__meta dt { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
.drawer__meta dd { margin: 0; font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.drawer__meta dd a { border-bottom: 1px solid var(--line-strong); }
.drawer__meta dd a:hover { color: var(--gold-light); }
.drawer__meta .select--compact select { min-width: 0; width: 100%; padding-block: 8px; }
.drawer__label { margin: 28px 0 10px; font-size: 10px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold); }
.drawer__problem {
  margin: 0;
  padding: 20px 22px;
  background: rgba(11, 9, 7, 0.55);
  border: 1px solid var(--line);
  border-left: 2px solid var(--gold);
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}
.drawer__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  z-index: 300;
  padding: 12px 22px;
  background: #1f1a14;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 13px;
  color: var(--gold-light);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.8);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .insights { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .console-bar { flex-wrap: wrap; }
  .clock, .pill { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .console__head { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 520px) {
  .console-bar__divider, .console-bar__label { display: none; }
  .kpi__num { font-size: 42px; }
  .drawer__meta { grid-template-columns: 1fr; }
  .toolbar .btn { flex: 1 1 auto; }
}
