:root {
  --bg-app: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #090d16;
  --border: #334155;
  --border-focus: #6366f1;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

.layout {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.logo-mark {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.brand-text h2 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

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

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.nav-tab.active {
  background: var(--bg-card);
  color: #fff;
  border-color: var(--border);
}

.badge-count {
  margin-left: auto;
  background: #334155;
  color: #cbd5e1;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 12px;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.btn-link {
  font-size: 12px;
  color: #a5b4fc;
  text-decoration: none;
}
.btn-link:hover {
  text-decoration: underline;
}

/* Main Content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.top-bar h1 {
  font-size: 24px;
  font-weight: 700;
}

.top-bar p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Grids and Cards */
.grid-2col {
  display: grid;
  grid-template-columns: 1.05fr 1.05fr;
  gap: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
}

.card h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Forms */
.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.flex-1 {
  flex: 1;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
}

.btn-voice {
  background: #1e1b4b;
  border: 1px solid #6366f1;
  color: #c7d2fe;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-voice.recording {
  background: #dc2626;
  color: #fff;
  border-color: #ef4444;
  animation: pulse 1s infinite alternate;
}
@keyframes pulse {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

.examples-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
}

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

.example-btn {
  background: #0f172a;
  border: 1px solid var(--border);
  color: #cbd5e1;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.example-btn:hover {
  background: #334155;
  color: #fff;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: #334155;
  color: #fff;
}
.btn-secondary:hover {
  background: #475569;
}

.btn-success {
  background: #059669;
  color: #fff;
}
.btn-success:hover {
  background: #10b981;
}

.btn-warning {
  background: #d97706;
  color: #fff;
}
.btn-warning:hover {
  background: #f59e0b;
}

.btn-tool {
  background: #1e1b4b;
  border: 1px solid #4f46e5;
  color: #c7d2fe;
  font-size: 12px;
  padding: 6px 12px;
}
.btn-tool:hover {
  background: #312e81;
  color: #fff;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-indicator {
  font-size: 13px;
  color: #a5b4fc;
}

/* Results Card */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  display: block;
}

.empty-state h4 {
  font-size: 16px;
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

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

.ticket-id-tag {
  font-weight: 700;
  font-size: 15px;
  color: #a5b4fc;
}

.lang-tag {
  background: #0f172a;
  border: 1px solid var(--border);
  color: #38bdf8;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
}

.badges-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sentiment-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  background: #334155;
  color: #f1f5f9;
}
.sentiment-badge.angry {
  background: #7f1d1d;
  color: #fecaca;
  border: 1px solid #dc2626;
}
.sentiment-badge.frustrated {
  background: #78350f;
  color: #fde68a;
  border: 1px solid #d97706;
}

.sla-badge {
  background: #1e1b4b;
  color: #c7d2fe;
  border: 1px solid #4338ca;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}

/* CRM Card */
.crm-card {
  background: #1e1b4b;
  border: 1px solid #3730a3;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.crm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}
.health-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  background: #15803d;
  color: #bbf7d0;
}
.health-badge.critical {
  background: #b91c1c;
  color: #fecaca;
}
.crm-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  font-size: 11px;
}
.crm-metrics small {
  color: #a5b4fc;
  display: block;
}
.crm-metrics strong {
  color: #fff;
  font-size: 13px;
}

.retention-banner {
  background: #450a0a;
  border: 1px solid #b91c1c;
  color: #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  margin-bottom: 16px;
}

.webhook-alert-box {
  background: #172554;
  border: 1px solid #2563eb;
  color: #bfdbfe;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 14px;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.metric-card small {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-card strong {
  font-size: 18px;
  color: #fff;
  margin: 4px 0;
  text-transform: capitalize;
}

.metric-sub {
  font-size: 11px;
  color: #a5b4fc;
}

/* Route Banner */
.route-banner {
  background: #172554;
  border: 1px solid #1e40af;
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.route-banner small {
  font-size: 11px;
  color: #93c5fd;
  text-transform: uppercase;
}

.route-banner h4 {
  font-size: 15px;
  color: #fff;
  margin: 2px 0;
}

.route-banner p {
  font-size: 12px;
  color: #bfdbfe;
}

.pill-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  background: #15803d;
  color: #bbf7d0;
}

.pill-badge.escalated {
  background: #b91c1c;
  color: #fecaca;
}

/* Action Tools Section */
.action-tools-card {
  background: #111827;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.tools-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.tool-receipt {
  margin-top: 10px;
  padding: 8px 12px;
  background: #064e3b;
  border: 1px solid #059669;
  border-radius: 6px;
  color: #a7f3d0;
  font-size: 12px;
}

/* KB Section */
.kb-section {
  margin-bottom: 16px;
}

.section-sub {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  display: block;
  margin-bottom: 6px;
}

.kb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kb-tag {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: #38bdf8;
}

/* Reply Section */
.reply-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.copy-link {
  font-size: 12px;
  color: #a5b4fc;
  cursor: pointer;
}

.reply-editor {
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.human-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.select-sm {
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
}

/* Table styles */
.table-card {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  background: #182234;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-triaged {
  background: #1e3a8a;
  color: #bfdbfe;
}
.status-escalated {
  background: #7f1d1d;
  color: #fecaca;
}
.status-resolved {
  background: #064e3b;
  color: #a7f3d0;
}

/* Filter controls */
.filter-controls {
  display: flex;
  gap: 8px;
}

.filter-btn {
  background: #1e293b;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

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

/* Batch Processing */
.file-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}

.file-drop-zone:hover {
  border-color: var(--primary);
}

.drop-icon {
  font-size: 36px;
  display: block;
  margin-bottom: 10px;
}

.hidden-file {
  display: none;
}

.action-bar-spread {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.batch-summary-placeholder {
  color: var(--text-muted);
  font-size: 14px;
  padding: 20px 0;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

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

.kpi-card h2 {
  font-size: 28px;
  margin: 6px 0;
  color: #fff;
}

.kpi-card small {
  font-size: 12px;
  color: #a5b4fc;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.chart-card {
  height: 320px;
  display: flex;
  flex-direction: column;
}

.chart-wrapper {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
}

/* Spikes Grid */
.spikes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.spike-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.spike-card h3 {
  font-size: 16px;
  color: #fff;
  margin-bottom: 8px;
}
.jira-box {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 12px;
  margin-top: 12px;
  font-family: monospace;
  font-size: 12px;
  color: #94a3b8;
  white-space: pre-wrap;
  max-height: 140px;
  overflow-y: auto;
}

/* Modal styles for Threading */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 580px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

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

.close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

.messages-container {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  max-width: 80%;
}

.message-bubble.customer {
  background: #1e293b;
  border: 1px solid var(--border);
  align-self: flex-start;
  color: #f1f5f9;
}

.message-bubble.agent {
  background: #312e81;
  border: 1px solid #4338ca;
  align-self: flex-end;
  color: #e0e7ff;
}

.message-bubble.system {
  background: #064e3b;
  border: 1px solid #059669;
  align-self: center;
  color: #a7f3d0;
  font-size: 12px;
  max-width: 90%;
  text-align: center;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
}


.pii-tag {
  background: #064e3b;
  border: 1px solid #059669;
  color: #a7f3d0;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
}

.csat-star-btn {
  background: #1e1b4b;
  border: 1px solid #4f46e5;
  color: #e0e7ff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.csat-star-btn:hover {
  background: #4338ca;
  color: #fff;
}
