/* Shared styles for login, rep and admin pages. */
:root {
  --bg: #f5f6f8;
  --surface: #fff;
  --text: #172033;
  --muted: #5d6679;
  --border: #dde1e8;
  --accent: #2557d6;
  --accent-text: #fff;
  --ok: #1a7f37;
  --ok-bg: #e3f4e8;
  --warn: #8a5a00;
  --warn-bg: #fff3cd;
  --err: #b00020;
  --err-bg: #fdecee;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --surface: #1a2029;
    --text: #e8ecf3;
    --muted: #9aa4b5;
    --border: #2d3644;
    --accent: #6c93ff;
    --accent-text: #0b1020;
    --ok: #5fd07f;
    --ok-bg: #16301f;
    --warn: #f1c453;
    --warn-bg: #3a2f10;
    --err: #ff7a8c;
    --err-bg: #3a151b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0 16px 48px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.page { max-width: 720px; margin: 0 auto; }
.page.wide { max-width: 1100px; }

h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 20px; }
h3 { font-size: 16px; margin: 24px 0 10px; }
a { color: var(--accent); cursor: pointer; }

/* Top bar */
.bar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 0; margin-bottom: 8px;
}
.bar .grow { flex: 1; min-width: 0; }
.bar .who { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Controls */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=file]), select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  min-height: 40px;
}
textarea { width: 100%; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  min-height: 40px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary, .call {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600;
}
.call { background: var(--ok); border-color: var(--ok); color: #fff; padding: 10px 22px; font-size: 16px; }
.rec-btn { flex: none; min-width: 92px; color: var(--err); border-color: var(--err); font-weight: 600; }
.rec-btn::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; background: currentColor; vertical-align: 0; }
.rec-btn.stop { background: var(--err); color: #fff; }
.rec-btn.stop::before { border-radius: 2px; }
.danger { color: var(--err); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.small { font-size: 13px; color: var(--muted); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 10px 0;
  box-shadow: var(--shadow);
}
.lead .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.lead .name { font-weight: 600; font-size: 16px; }
.lead .row { margin-top: 10px; }
.lead textarea { margin-top: 10px; }

/* Status pills */
.pill {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted);
  border: 1px solid var(--border); white-space: nowrap;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.live { background: var(--err-bg); color: var(--err); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

/* Messages and banners */
#msg { color: var(--err); margin: 0; min-height: 0; }
#msg:not(:empty) { background: var(--err-bg); padding: 8px 12px; border-radius: 8px; margin: 8px 0; }
#banner { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 8px; margin: 8px 0; display: none; }

/* Recorder panel (laptop) */
#recorder.card.live { border-color: var(--err); background: var(--err-bg); }
.rec-head { display: flex; align-items: flex-start; gap: 10px; }
.rec-head .grow { flex: 1; min-width: 0; }
#rec-status { margin-top: 2px; }
.dot { flex: none; width: 12px; height: 12px; margin-top: 5px; border-radius: 50%; background: var(--muted); }
.dot.ready { background: var(--ok); }
.dot.busy { background: var(--accent); }
.dot.warn { background: var(--warn); }
.dot.live { background: var(--err); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .dot.live { animation: none; } }
.timer { font: 600 20px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--err); font-variant-numeric: tabular-nums; }
.mic-btn { width: 100%; margin-top: 12px; }
.meter { height: 6px; margin-top: 12px; border-radius: 999px; background: var(--border); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--err); transition: width 80ms linear; }
.local-title { margin: 14px 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.local-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.local-item .meta { flex: 1; min-width: 0; }
.local-item .who-lead { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.local-item .save { font-size: 13px; font-weight: 600; text-decoration: none; }

/* Laptop: leads on the left, recorder and call history in a column on the right. */
.cols { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "rec" "leads" "history"; }
#recorder { grid-area: rec; }
#leads { grid-area: leads; min-width: 0; }
#history { grid-area: history; min-width: 0; }
@media (min-width: 900px) {
  .laptop .cols {
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-areas: "leads rec" "leads history";
    grid-template-rows: auto 1fr;
    column-gap: 20px; align-items: start;
  }
  .laptop #history h3 { margin-top: 14px; }
}

/* Call history items */
.call-item { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.call-item .meta { min-width: 0; }
.call-item .who-lead { font-weight: 600; }

/* Tables (admin) */
.wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 12px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg); }
td select { min-height: 34px; padding: 4px 8px; }
audio { height: 34px; max-width: 240px; }
section { margin-bottom: 8px; }
.toolbar { display: flex; gap: 10px 12px; flex-wrap: wrap; align-items: end; margin: 10px 0; }
.toolbar label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.toolbar .sep { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* Login */
.auth { max-width: 380px; margin: 0 auto; padding-top: 12vh; }
.auth h2 { font-size: 24px; margin-bottom: 4px; }
.auth .sub { color: var(--muted); margin: 0 0 18px; }
.auth form { display: grid; gap: 10px; }
.auth input, .auth button { width: 100%; min-height: 46px; }
