:root {
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Background Gradients */
.bg-accent {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: -1;
  opacity: 0.15;
}
.bg-accent-1 {
  top: -10%;
  left: -10%;
  width: 500px;
  height: 500px;
  background: var(--primary);
}
.bg-accent-2 {
  bottom: -10%;
  right: -10%;
  width: 600px;
  height: 600px;
  background: #8b5cf6;
}

/* Utilities */
.hidden { display: none !important; }

/* Screens */
.screen {
  height: 100vh;
  width: 100vw;
  display: flex;
}

/* Auth Screen */
#auth-screen {
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px;
  text-align: center;
  max-width: 440px;
  width: 90%;
  box-shadow: var(--glass-shadow);
  animation: slideUp 0.5s ease;
}

.auth-logo {
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, #60a5fa, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
}

.auth-card h1 {
  font-size: 28px;
  margin-bottom: 12px;
}

.auth-card p {
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.5;
}

.error-msg {
  margin-top: 16px;
  color: #fca5a5;
  font-size: 14px;
  background: rgba(239, 68, 68, 0.1);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Layout */
#app-screen {
  flex-direction: row;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px;
}

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

.brand-logo {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.brand-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.5px;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 10px;
  font-weight: 500;
  transition: all 0.2s;
}

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

.nav-link.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  padding: 2px 0;
}
.btn-text:hover {
  color: var(--text-main);
  text-decoration: underline;
}

/* Main Content */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 40px;
  overflow-y: auto;
  min-height: 0; /* Fixes flexbox child expanding past parent */
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.topbar h2 {
  font-size: 24px;
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: inherit;
}

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

.secondary-btn {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}
.secondary-btn:hover { background: rgba(255, 255, 255, 0.15); }

.danger-btn {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.danger-btn:hover {
  background: var(--danger);
  color: white;
}

.action-btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}
.action-btn.archive-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.icon-btn {
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

/* Projects Table Area */
.projects-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1; /* Allow container to grow but scroll contents */
}

.table-responsive {
  overflow-y: auto;
  flex: 1;
}

.controls-bar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 16px;
}

.search-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 8px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus {
  border-color: var(--primary);
}

.loading-state {
  padding: 60px;
  text-align: center;
  color: var(--text-muted);
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

.projects-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.projects-table th {
  padding: 16px 24px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.projects-table td {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 14px;
}

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

.projects-table tr:last-child td {
  border-bottom: none;
}

.project-code-cell {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
}
.project-icon {
  color: var(--primary);
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.2s;
}
.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal.hidden .modal-content {
  transform: translateY(20px);
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.btn-close:hover { color: var(--text-main); }

.modal-body {
  padding: 24px;
}

.modal-desc {
  margin-bottom: 24px;
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 14px;
}
.highlight-text {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.form-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 8px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.form-input:focus { border-color: var(--primary); }

.form-input option {
  background: #1e293b;
  color: var(--text-main);
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(0, 0, 0, 0.1);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

/* Process Steps (Archiving) */
.process-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.process-step {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.3s;
}
.process-step.pending {
  opacity: 0.5;
}
.process-step.active {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.05);
}
.process-step.success {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.05);
}
.process-step.error {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.05);
}

.step-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
}
.step-text {
  font-size: 14px;
  font-weight: 500;
}

.spinner-small {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
}

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

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

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 32px;
  right: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
}

.toast {
  background: rgba(16, 185, 129, 0.15);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  padding: 16px 24px;
  border-radius: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  transform: translateX(120%);
  animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.toast-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.toast.toast-info {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

.toast.hiding {
  animation: slideOutRight 0.3s ease-in forwards;
}

@keyframes slideInRight {
  to { transform: translateX(0); }
}

@keyframes slideOutRight {
  to { transform: translateX(120%); }
}

/* Owner indicators & restrictions */
.owner-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  margin-left: 8px;
  vertical-align: middle;
}

.owner-pill.owner-pill-mine {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

.action-btn.disabled-btn {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: auto; /* allows title hover tooltip */
}

.project-row-disabled td:not(:first-child) {
  opacity: 0.85;
}

input[type="checkbox"]:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

