:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --green: #059669;
  --green-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 25px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 30;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  display: grid;
  place-items: center;
  letter-spacing: -0.5px;
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-label-row .section-label {
  margin-bottom: 0;
}

.date-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.date-item {
  width: 100%;
  text-align: left;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: inherit;
}

.date-item:hover {
  border-color: #c7d2fe;
  background: #f5f7ff;
}

.date-item.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.date-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--text);
}

.date-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-muted);
}

.mini-tag {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 500;
}

.mini-tag.rec {
  color: var(--primary);
  border-color: #c7d2fe;
  background: #eef2ff;
}

.mini-tag.no-sum {
  color: var(--amber);
  border-color: #fde68a;
  background: var(--amber-soft);
}

/* Summary Card */
.summary-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.summary-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--text);
}

.summary-files {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  word-break: break-all;
}

.talk-highlight {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.talk-highlight-label {
  font-size: 12px;
  opacity: 0.92;
}

.talk-highlight-val {
  font-size: 18px;
  font-weight: 700;
}

.summary-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  padding: 5px 0;
  border-bottom: 1px dashed #e2e8f0;
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row-label {
  color: #334155;
}

.summary-row-val {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.no-summary-box {
  text-align: center;
  padding: 18px 10px;
}

.no-summary-pill {
  display: inline-block;
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid #fde68a;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 8px;
}

/* Main Content */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 20px 24px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--surface-alt);
  border-color: #cbd5e1;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: #e2e8f0;
  color: var(--text);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 7px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.text-blue { color: var(--blue); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }
.text-indigo { color: var(--primary); }

/* Filters */
.filters-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quick-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover {
  border-color: #c7d2fe;
  color: var(--text);
}

.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.search-wrap input:focus,
.filter-controls select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.filter-controls select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

/* Table Panel */
.table-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}

.page-limit-tag {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}

.table-responsive {
  overflow-x: auto;
}

.calls-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.calls-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}

.calls-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.calls-table tbody tr:hover {
  background: #f8fafc;
}

.empty-cell {
  text-align: center;
  padding: 32px 16px !important;
  color: var(--text-muted);
}

.phone-cell {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sub-cell {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* Audio Player Widget */
.audio-widget {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px 4px 5px;
  min-width: 175px;
}

.audio-widget.playing {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.audio-play-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 11px;
  flex-shrink: 0;
}

.audio-play-btn:hover {
  background: var(--primary-hover);
}

.audio-meta {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.audio-progress-track {
  width: 100%;
  height: 4px;
  background: #cbd5e1;
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
}

.audio-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.1s linear;
}

.audio-time {
  font-size: 10.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.audio-err {
  color: var(--red);
  font-size: 10.5px;
}

/* Pagination */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}

.page-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Mobile Cards (hidden on desktop) */
.mobile-cards {
  display: none;
  padding: 12px;
  flex-direction: column;
  gap: 12px;
}

.call-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.call-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.call-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  font-size: 12px;
}

.call-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal-dialog {
  position: relative;
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 17px;
}

.modal-subtitle {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.detail-item-label {
  font-size: 11px;
  color: var(--text-muted);
}

.detail-item-val {
  font-size: 13px;
  font-weight: 600;
}

.transcript-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.t-turn {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.t-turn.bot {
  background: #eef2ff;
  border-left: 3px solid var(--primary);
}

.t-turn.customer {
  background: #ecfdf5;
  border-left: 3px solid var(--green);
}

.mobile-only {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.muted-text {
  color: var(--text-muted);
  font-size: 12.5px;
}

.skeleton-line {
  height: 44px;
  border-radius: 10px;
  background: #f1f5f9;
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .mobile-only {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    left: -340px;
    top: 0;
    bottom: 0;
    transition: left 0.22s ease;
    box-shadow: var(--shadow-md);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 25;
  }

  .main-content {
    padding: 16px;
  }
}

@media (max-width: 768px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-responsive {
    display: none;
  }

  .mobile-cards {
    display: flex;
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
