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

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --secondary: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --border: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

#app {
  max-width: 100%;
  margin: 0 auto;
  padding-bottom: 32px;
}

/* Header */
.header {
  background: var(--bg-primary);
  border-bottom: 2px solid var(--primary);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.header h1 {
  font-size: 1.5em;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.user-info {
  display: flex;
  gap: 12px;
  align-items: center;
}

.help-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9em;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.help-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.lang-selector {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
  transition: all 0.2s;
}

.lang-selector:hover {
  border-color: var(--primary);
  background: var(--bg-tertiary);
}

.lang-selector:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.user-email {
  font-size: 0.9em;
  color: var(--text-secondary);
}

.user-role {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 600;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.user-role.owner {
  background: #fef3c7;
  color: #92400e;
}

.user-role.editor {
  background: #dbeafe;
  color: #1e40af;
}

.user-role.viewer {
  background: #e5e7eb;
  color: #374151;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: all 0.2s;
  position: relative;
}

.tab-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-primary);
  color: var(--primary);
  font-weight: 600;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}

/* Tab Content */
.tab-content {
  display: none;
  padding: 20px;
  background: var(--bg-primary);
  min-height: calc(100vh - 180px);
}

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

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

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

/* Buttons */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95em;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.icon {
  font-size: 1.1em;
}

/* Filters */
.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.95em;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Requests List */
.requests-list {
  display: grid;
  gap: 12px;
}

.request-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.request-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.request-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 12px;
}

.request-title {
  font-weight: 600;
  font-size: 1.05em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.request-type {
  font-size: 0.85em;
  color: var(--text-secondary);
}

.request-status {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
}

.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.status-approved {
  background: #d1fae5;
  color: #065f46;
}

.status-rejected {
  background: #fee2e2;
  color: #991b1b;
}

.status-cancelled {
  background: #e5e7eb;
  color: #374151;
}

.request-meta {
  display: flex;
  gap: 16px;
  font-size: 0.9em;
  color: var(--text-secondary);
  margin-top: 8px;
}

.request-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Workflow Config */
.workflow-config {
  max-width: 1200px;
}

.config-section {
  margin-bottom: 32px;
}

.config-section h3 {
  font-size: 1.1em;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.workflow-types-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.workflow-type-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.workflow-canvas {
  background: var(--bg-secondary);
  border: 2px dashed var(--border);
  border-radius: 8px;
  min-height: 400px;
  padding: 20px;
  position: relative;
}

/* Audit Log */
.audit-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.date-input,
.text-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95em;
}

.date-input:focus,
.text-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.audit-log {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.audit-entry {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: start;
}

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

.audit-timestamp {
  font-size: 0.85em;
  color: var(--text-secondary);
  min-width: 140px;
}

.audit-action {
  flex: 1;
}

.audit-user {
  font-weight: 600;
  color: var(--primary);
}

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

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-card h3 {
  font-size: 0.9em;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2em;
  font-weight: 700;
  color: var(--primary);
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: slideUp 0.3s ease-out;
}

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

.modal-header {
  padding: 24px 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5em;
  font-weight: 600;
  color: white;
}

.modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: white;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.modal-body {
  padding: 28px;
  overflow-y: auto;
  max-height: calc(90vh - 100px);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95em;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Timeline */
.workflow-timeline {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.timeline-item {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: -20px;
  width: 2px;
  background: var(--border);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  flex-shrink: 0;
  z-index: 1;
}

.timeline-icon.pending {
  background: #fef3c7;
  color: #92400e;
}

.timeline-icon.approved {
  background: #d1fae5;
  color: #065f46;
}

.timeline-icon.rejected {
  background: #fee2e2;
  color: #991b1b;
}

.timeline-content {
  flex: 1;
}

.timeline-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.timeline-meta {
  font-size: 0.85em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.timeline-comment {
  margin-top: 8px;
  padding: 12px;
  background: white;
  border-radius: 8px;
  font-size: 0.9em;
  color: var(--text-primary);
  border-left: 3px solid var(--primary);
}

/* Request Details Styling */
.detail-row {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 10px;
  border-left: 4px solid var(--primary);
}

.detail-label {
  display: block;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.detail-row p {
  margin: 8px 0 0 0;
  color: var(--text-primary);
  line-height: 1.6;
}

.workflow-timeline h3 {
  font-size: 1.2em;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.workflow-timeline h3::before {
  content: '📋';
  font-size: 1.3em;
}

.validation-actions {
  margin-top: 32px;
  padding: 24px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  border-radius: 12px;
}

.validation-form h3 {
  font-size: 1.2em;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.validation-form h3::before {
  content: '✍️';
  font-size: 1.3em;
}

.validation-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.validation-buttons .btn {
  flex: 1;
  padding: 14px 24px;
  font-size: 1em;
  font-weight: 600;
  border-radius: 10px;
  transition: all 0.2s;
}

.validation-buttons .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.no-permission {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-style: italic;
}

/* Spinner */
.spinner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Guide Styles */
.guide-section {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
  background: var(--bg-primary);
}

.guide-header {
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--border);
}

.guide-header h1 {
  color: var(--primary);
  margin-bottom: 12px;
  font-size: 2em;
}

.guide-intro {
  color: var(--text-secondary);
  font-size: 1.1em;
}

.guide-section-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.guide-section-item h2 {
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--bg-tertiary);
  font-size: 1.5em;
}

.guide-section-item h3 {
  color: var(--text-primary);
  margin-top: 20px;
  margin-bottom: 12px;
  font-size: 1.2em;
}

.guide-section-item p {
  line-height: 1.6;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.guide-section-item ul,
.guide-section-item ol {
  margin-left: 24px;
  margin-bottom: 16px;
  line-height: 1.8;
}

.guide-section-item li {
  margin-bottom: 8px;
  color: var(--text-primary);
}

.guide-section-item code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: var(--primary);
}

.guide-section-item a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.guide-section-item a:hover {
  text-decoration: underline;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9em;
}

.guide-table th,
.guide-table td {
  border: 1px solid var(--border);
  padding: 10px;
  text-align: left;
}

.guide-table th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
}

.guide-table tr:nth-child(even) {
  background: var(--bg-secondary);
}

.guide-table tr:hover {
  background: var(--bg-tertiary);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 4em;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.2em;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .filters {
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    margin: 0;
    max-height: 100vh;
    border-radius: 0;
  }
}
