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

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --danger: #DC2626;
  --danger-hover: #B91C1C;
  --danger-light: #FEF2F2;
  --success: #16A34A;
  --success-light: #F0FDF4;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --transition: 150ms ease;
}

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

.hidden { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: none; background: transparent; cursor: pointer;
  border-radius: var(--radius); color: var(--text-muted);
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

.input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* Login Screen */
.screen { min-height: 100vh; }
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
  background: var(--surface);
  padding: 48px;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 400px;
  width: 100%;
}
.login-logo { margin-bottom: 20px; }
.login-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.login-subtitle { color: var(--text-secondary); font-size: 15px; margin-bottom: 32px; }
.login-note { margin-top: 16px; font-size: 12px; color: var(--text-muted); }
#login-btn { width: 100%; justify-content: center; }

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-title { font-size: 16px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; }
.user-email { font-size: 13px; color: var(--text-secondary); }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 12px 20px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Upload Area */
.upload-area {
  max-width: 900px;
  margin: 32px auto;
  padding: 0 24px;
}
.upload-columns {
  display: flex;
  gap: 0;
  align-items: stretch;
  margin-bottom: 24px;
}
.upload-column { flex: 1; }
.upload-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding: 0 4px;
}
.upload-divider {
  display: flex;
  align-items: center;
  padding: 0 20px;
  padding-top: 24px;
}
.upload-divider span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.drop-zone svg { margin-bottom: 12px; opacity: .5; }
.drop-zone p { font-size: 14px; margin-bottom: 4px; }
.drop-zone .browse-link { color: var(--primary); font-weight: 500; cursor: pointer; }
.drop-hint { font-size: 12px !important; color: var(--text-muted); }
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--success-light);
  border: 1px solid #BBF7D0;
  border-radius: var(--radius-lg);
}
.file-info { display: flex; align-items: center; gap: 8px; color: var(--success); }
.file-name { font-size: 14px; font-weight: 500; color: var(--text); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remove-file { color: var(--text-muted); }

#compare-btn { width: 100%; justify-content: center; }
#compare-btn.loading {
  pointer-events: none;
  opacity: .7;
}

/* History */
.comparison-list {
  max-width: 900px;
  margin: 24px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.comparison-card {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--transition);
  cursor: pointer;
}
.comparison-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}
.comparison-card-info { flex: 1; min-width: 0; }
.comparison-card-files {
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.comparison-card-files .file-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
}
.comparison-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}
.comparison-card-meta .shared-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
}
.comparison-card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}
.comparison-card:hover .comparison-card-actions { opacity: 1; }

/* Loading / Empty states */
.loading-state, .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; }
.empty-state p { font-size: 16px; font-weight: 500; }
.text-muted { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Overlay (Viewer) */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.overlay-title {
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.vs-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
}
.overlay-actions { display: flex; gap: 4px; }
.viewer-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  margin: 24px;
}
.modal-sm { max-width: 400px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* Share */
.share-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.share-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.share-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 14px;
}
.share-item-email { color: var(--text-secondary); }
.share-item-remove {
  border: none; background: none; cursor: pointer;
  color: var(--text-muted); font-size: 13px;
  padding: 2px 8px; border-radius: 4px;
  transition: all var(--transition);
}
.share-item-remove:hover { background: var(--danger-light); color: var(--danger); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  animation: toast-in .3s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 200;
  padding: 4px;
}
.dropdown-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  font-family: inherit;
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item strong { font-size: 13px; font-weight: 600; color: var(--text); }
.dropdown-item span { font-size: 12px; color: var(--text-muted); }

/* Responsive */
@media (max-width: 640px) {
  .upload-columns { flex-direction: column; }
  .upload-divider { padding: 12px 0; justify-content: center; }
  .comparison-card-actions { opacity: 1; }
}
