:root {
  --primary: #0078d4;
  --primary-dark: #005a9e;
  --primary-light: #deecf9;
  --success: #107c10;
  --warning: #ff8c00;
  --danger: #d13438;
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #e5e5e5;
  --gray-300: #d4d4d4;
  --gray-400: #a3a3a3;
  --gray-500: #737373;
  --gray-600: #525252;
  --gray-700: #404040;
  --gray-800: #262626;
  --gray-900: #171717;
  --sidebar-width: 240px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
}

.hidden { display: none !important; }

.login-container {
  max-width: 400px;
  margin: 120px auto;
  padding: 40px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-container h1 { color: var(--primary); margin-bottom: 8px; }
.login-container p { color: var(--gray-500); margin-bottom: 24px; }

.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 14px; }

.form-input, input[type="text"], input[type="password"], input[type="date"], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-input:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #a80000; }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-600); }
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

.error-msg { color: var(--danger); font-size: 14px; margin-top: 12px; }

#dashboard { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
}

.sidebar-header { padding: 20px; border-bottom: 1px solid var(--gray-700); }
.sidebar-header h2 { font-size: 20px; color: var(--primary); }
.sidebar-header .subtitle { font-size: 12px; color: var(--gray-400); }

.nav-links { list-style: none; padding: 12px 0; flex: 1; }

.nav-link {
  display: block;
  padding: 10px 20px;
  color: var(--gray-300);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
}

.nav-link:hover { background: var(--gray-800); color: white; }
.nav-link.active { background: var(--primary); color: white; border-radius: 0; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--gray-700); }

.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px;
  min-width: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-actions { display: flex; gap: 8px; }

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.mt-4 { margin-top: 20px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

.stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 14px; color: var(--gray-500); margin-top: 4px; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 12px; font-size: 12px; text-transform: uppercase; color: var(--gray-500); border-bottom: 2px solid var(--gray-200); }
.data-table td { padding: 12px; border-bottom: 1px solid var(--gray-100); font-size: 14px; }
.data-table tr:hover { background: var(--gray-50); }

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-active, .status-completed { background: #e6f4ea; color: var(--success); }
.status-pending, .status-scheduled, .status-fetching, .status-sanitizing { background: #fff3cd; color: var(--warning); }
.status-error, .status-failed, .status-expired { background: #fde7e7; color: var(--danger); }
.status-recording, .status-transcript_pending { background: var(--primary-light); color: var(--primary); }
.status-cancelled { background: var(--gray-200); color: var(--gray-500); }
.status-raw_stored { background: #e0f2fe; color: #0284c7; }

.empty-state { text-align: center; padding: 40px; color: var(--gray-400); font-size: 16px; }

.filters-bar { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; }
.filters-bar .form-input, .filters-bar select, .filters-bar input { width: auto; min-width: 160px; }

.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }

.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; }

.health-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: 6px;
}

.health-dot { width: 10px; height: 10px; border-radius: 50%; }
.health-dot.connected { background: var(--success); }
.health-dot.disconnected { background: var(--danger); }
.health-dot.unknown { background: var(--gray-400); }

.readonly-field {
  padding: 10px 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 14px;
  color: var(--gray-600);
  font-family: monospace;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-large { max-width: 800px; }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-footer { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; }

.transcript-tabs { display: flex; gap: 4px; margin-bottom: 12px; }

.tab-btn {
  padding: 8px 16px;
  border: 1px solid var(--gray-300);
  background: white;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 14px;
}

.tab-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.transcript-content {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 16px;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.6;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
}

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-header h2 { font-size: 14px; }
  .sidebar-header .subtitle { display: none; }
  .nav-link { padding: 10px; font-size: 0; }
  .content { margin-left: 60px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filters-bar { flex-wrap: wrap; }
}
