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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #232733;
  --border: #2e3344;
  --text: #e4e6ed;
  --text2: #9499ad;
  --primary: #4f8ff7;
  --primary-hover: #3a7de6;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --orange: #fb923c;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

.logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.logo span { color: var(--primary); }

#user-info {
  font-size: 14px;
  color: var(--text2);
}
#user-info .role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  margin-left: 8px;
}
#user-info .role-admin { background: rgba(79,143,247,0.2); color: var(--primary); }
#user-info .role-broker { background: rgba(52,211,153,0.2); color: var(--green); }

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
}

.screen { display: none; }
.screen.active { display: block; }

h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.toolbar h2 { margin-bottom: 0; }

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-approve { background: rgba(52,211,153,0.2); color: var(--green); }
.btn-reject { background: rgba(248,113,113,0.2); color: var(--red); }

/* User Selection */
.user-list {
  display: grid;
  gap: 12px;
}
.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: border-color 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.user-card:hover { border-color: var(--primary); }
.user-card .name { font-weight: 600; }
.user-card .meta { font-size: 13px; color: var(--text2); }

/* Sessions List */
.sessions-list { display: grid; gap: 10px; }
.session-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.session-card:hover { border-color: var(--primary); }
.session-card .session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.session-card .session-title { font-weight: 600; font-size: 15px; }
.session-card .session-preview {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.status-completed { background: rgba(52,211,153,0.15); color: var(--green); }
.status-summarized, .status-extracted { background: rgba(79,143,247,0.15); color: var(--primary); }
.status-review_required { background: rgba(251,191,36,0.15); color: var(--yellow); }
.status-failed { background: rgba(248,113,113,0.15); color: var(--red); }
.status-created, .status-submitted, .status-recording { background: rgba(148,153,173,0.15); color: var(--text2); }

/* Form */
form { display: grid; gap: 16px; }
label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
}
input, select, textarea {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Input mode tabs */
.input-mode-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: fit-content;
}
.input-mode-tabs .tab {
  padding: 8px 20px;
  background: var(--surface);
  border: none;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.input-mode-tabs .tab:not(:last-child) { border-right: 1px solid var(--border); }
.input-mode-tabs .tab.active { background: var(--primary); color: #fff; }
.input-mode-tabs .tab:hover:not(.active) { background: var(--surface2); }

.input-panel { display: none; }
.input-panel.active { display: block; }

/* Voice recorder */
.voice-recorder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.voice-status {
  font-size: 14px;
  color: var(--text2);
  text-align: center;
}
.voice-status.recording { color: var(--red); font-weight: 600; }
.voice-status.error { color: var(--red); }
.voice-status.success { color: var(--green); }

.voice-timer {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: 2px;
}
.voice-timer.recording { color: var(--red); }

.voice-visualizer {
  width: 100%;
  max-width: 400px;
  height: 60px;
  background: var(--surface2);
  border-radius: var(--radius);
  overflow: hidden;
}
.voice-visualizer canvas {
  width: 100%;
  height: 100%;
}

.btn-mic {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.btn-mic:hover { border-color: var(--primary); color: var(--primary); }
.btn-mic.recording {
  border-color: var(--red);
  background: rgba(248,113,113,0.15);
  color: var(--red);
  animation: pulse-ring 1.5s ease-in-out infinite;
}
@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,0.3); }
  50% { box-shadow: 0 0 0 12px rgba(248,113,113,0); }
}

.voice-transcript-container {
  width: 100%;
}
.voice-transcript-container textarea {
  width: 100%;
}
.transcript-hint {
  font-size: 12px;
  color: var(--text2);
  margin-top: 6px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px 20px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none; }

/* Result */
.result-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.result-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--primary);
}
.result-section p, .result-section li {
  font-size: 14px;
  line-height: 1.6;
}
.result-section ul { padding-left: 20px; }
.result-section li { margin-bottom: 4px; }

/* Facts table */
.facts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.facts-table th, .facts-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.facts-table th {
  color: var(--text2);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
}
.confidence-high { color: var(--green); }
.confidence-medium { color: var(--yellow); }
.confidence-low { color: var(--red); }

.review-actions {
  display: flex;
  gap: 6px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text2);
}

/* Share / Copy actions */
.share-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 0 4px;
}

/* Header */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 440px;
}
.modal-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Admin user table */
.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
}
.admin-user-row .user-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.admin-user-row .user-name { font-weight: 600; font-size: 14px; }
.admin-user-row .user-email { font-size: 13px; color: var(--text2); }
.admin-user-row .user-actions { display: flex; align-items: center; gap: 8px; }
.admin-user-row.inactive { opacity: 0.5; }

/* Login error in forms */
.login-error {
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  display: none;
}
.login-error.visible { display: block; }
