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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e4e4e7;
  --text-muted: #8b8d98;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --success: #22c55e;
}

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

/* Layout */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

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

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

header .user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

header .user-info span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Buttons */
button, .btn {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: white; }

.btn-small {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

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

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 380px;
}

.login-card h2 {
  margin-bottom: 0.5rem;
}

.login-card p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* Forms */
input[type="tel"],
input[type="text"],
textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

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

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.success {
  color: var(--success);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Dashboard */
.dashboard {
  padding: 2rem;
  max-width: 900px;
  margin: 0 auto;
}

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.section h3 {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.file-list {
  margin-top: 1rem;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.file-item:last-child { border-bottom: none; }

.file-item .file-name {
  color: var(--text);
}

.file-item .file-size {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Status */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-pending { background: #292524; color: #fbbf24; }
.status-complete { background: #052e16; color: #22c55e; }

/* OTP code input */
.otp-input {
  letter-spacing: 0.5em;
  text-align: center;
  font-size: 1.5rem;
  font-family: monospace;
}

/* Hidden */
.hidden { display: none; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Generate section */
.generate-controls {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.generate-controls textarea {
  flex: 1;
  min-height: 80px;
  resize: vertical;
}

/* Progress stages */
.generation-progress {
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
}

.progress-stages {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-stages .stage {
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  background: var(--bg);
  transition: all 0.3s;
}

.progress-stages .stage.active {
  color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
  font-weight: 600;
}

.progress-stages .stage.done {
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

.progress-stages .stage-arrow {
  color: var(--border);
  font-size: 1rem;
}

/* Navigation tabs */
.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-tabs {
  display: flex;
  gap: 0.25rem;
}

.nav-tab {
  padding: 0.4rem 1rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

/* Admin panel */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 0.4rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.audit-controls {
  margin-bottom: 1rem;
}

/* Audit feed */
.audit-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.audit-entry:last-child { border-bottom: none; }

.audit-entry .audit-action {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.audit-entry .audit-action-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  min-width: 70px;
  text-align: center;
}

.badge-login    { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.badge-upload   { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.badge-generate { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.badge-download { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-logout   { background: rgba(139, 141, 152, 0.15); color: var(--text-muted); }

.audit-entry .audit-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.audit-entry .audit-practitioner {
  color: var(--text);
}

/* Practitioner breakdown */
.practitioner-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

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

.practitioner-name {
  font-weight: 500;
}

.practitioner-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.practitioner-stat-val {
  color: var(--text);
  font-weight: 600;
}

/* Login row */
.login-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

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

/* Empty state */
.empty-state {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 1rem 0;
  text-align: center;
}

/* Add practitioner form */
.add-practitioner-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.form-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.form-input-sm {
  padding: 0.45rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  margin-bottom: 0;
}

.form-input-sm:focus {
  outline: none;
  border-color: var(--accent);
}

select.form-input-sm {
  appearance: auto;
  cursor: pointer;
}

/* Practitioner list */
.practitioner-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.practitioner-entry:last-child { border-bottom: none; }

.practitioner-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.practitioner-info .pract-name {
  font-weight: 500;
}

.practitioner-info .pract-phone {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.role-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.role-practitioner { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.role-admin { background: rgba(99, 102, 241, 0.15); color: var(--accent); }

/* Document history */
.history-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.history-entry:last-child { border-bottom: none; }

.history-action {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.history-time {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-row {
    flex-direction: column;
  }
  .form-input-sm {
    width: 100%;
  }
}
