:root {
  --bg: #0b0d12;
  --bg-elevated: #12151c;
  --card-bg: #161a23;
  --card-bg-hover: #1a1f2b;
  --border: #262b38;
  --border-soft: #1e222d;
  --text: #e6e8ec;
  --muted: #8a90a2;
  --accent: #6d8dff;
  --accent-dark: #4f6fe0;
  --accent-soft: rgba(109, 141, 255, 0.12);
  --positive: #22c55e;
  --positive-soft: rgba(34, 197, 94, 0.15);
  --negative: #f43f5e;
  --negative-soft: rgba(244, 63, 94, 0.15);
  --neutral: #94a3b8;
  --neutral-soft: rgba(148, 163, 184, 0.15);
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(109, 141, 255, 0.08), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(109, 141, 255, 0.05), transparent 35%),
    var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", "Tahoma", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 21, 28, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  padding: 0.9rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.logout-link, .back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.logout-link:hover, .back-link:hover { color: #a9bcff; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* ---------- login ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: linear-gradient(180deg, var(--card-bg), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.25rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.login-box h1 {
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
  text-align: center;
  font-weight: 600;
}

.login-box label {
  font-size: 0.85rem;
  color: var(--muted);
}

.login-box input {
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.login-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-box button {
  padding: 0.7rem;
  background: var(--accent);
  color: #0b0d12;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.login-box button:hover { background: var(--accent-dark); }

.error {
  color: var(--negative);
  font-size: 0.85rem;
  margin: 0;
  background: var(--negative-soft);
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
}

/* ---------- filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.filters input, .filters select {
  flex: 1 1 150px;
  min-width: 0;
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.9rem;
  color-scheme: dark;
}

.filters input:focus, .filters select:focus {
  outline: none;
  border-color: var(--accent);
}

.filters button {
  padding: 0.55rem 1.2rem;
  background: var(--accent);
  color: #0b0d12;
  border: none;
  border-radius: 7px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.filters button:hover { background: var(--accent-dark); }

.clear-link {
  align-self: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}

.clear-link:hover { color: var(--text); }

.result-count {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

/* ---------- calls table (desktop) ---------- */
.calls-table {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.calls-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 0.7fr 0.6fr 0.6fr 0.7fr 1.4fr 0.6fr;
  gap: 0.5rem;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.95rem;
  transition: background 0.15s, border-color 0.15s;
}

.calls-row:not(.calls-head):hover {
  background: var(--card-bg-hover);
  border-color: #333a4a;
}

.calls-head {
  background: transparent;
  border: none;
  font-size: 0.76rem;
  color: var(--muted);
  padding: 0 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}

.badge-positive { background: var(--positive-soft); color: var(--positive); }
.badge-negative { background: var(--negative-soft); color: var(--negative); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral); }
.badge-none { background: var(--border-soft); color: var(--muted); }

.download-link, .details-link {
  display: inline-block;
  margin-top: 0.3rem;
  font-size: 0.82rem;
  color: var(--accent);
  text-decoration: none;
}

.download-link:hover, .details-link:hover { color: #a9bcff; }

.muted { color: var(--muted); font-size: 0.85rem; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 0;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.pagination a {
  color: var(--accent);
  text-decoration: none;
}

.pagination a:hover { color: #a9bcff; }

/* audio player - dark-friendly */
audio {
  filter: invert(0.85) hue-rotate(180deg);
  border-radius: 20px;
}

/* ---------- mobile: table becomes stacked cards ---------- */
@media (max-width: 800px) {
  .calls-head { display: none; }

  .calls-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .calls-row > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.3rem 0;
    border-bottom: 1px dashed var(--border-soft);
    font-size: 0.9rem;
  }

  .calls-row > div:last-child { border-bottom: none; }

  .calls-row > div[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    flex-shrink: 0;
  }

  .filters { flex-direction: column; }
  .filters input, .filters select, .filters button { flex: 1 1 auto; width: 100%; }
}

/* ---------- detail page ---------- */
.detail .card {
  background: linear-gradient(180deg, var(--card-bg), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.1rem;
}

.detail .card h2 {
  font-size: 1rem;
  margin: 0 0 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.detail .card h3 {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 1.1rem 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1.2rem;
  margin: 0;
}

.kv dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.kv dd {
  margin: 0;
  font-size: 0.9rem;
}

@media (max-width: 600px) {
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 0.5rem; }
}

.transcript {
  white-space: pre-wrap;
  font-size: 0.92rem;
  line-height: 1.9;
  color: #d3d6dd;
}

.back-link {
  display: inline-block;
  margin-bottom: 1.1rem;
}
