:root {
  font-family: 'Segoe UI', Roboto, sans-serif;
  background-color: #f2ecf8;
  color: #2d0f40;
}

body {
  margin: 0;
  padding: 0;
  background: linear-gradient(160deg, #f2ecf8 0%, #fff4ff 60%, #fdfcfe 100%);
  min-height: 100vh;
}

.app-header {
  background: #4b176a;
  color: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(75, 23, 106, 0.3);
}

.app-header h1 {
  margin: 0;
  font-size: 1.5rem;
  color: white;
}

main {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 2rem;
  display: grid;
  gap: 1.5rem;
}

.panel {
  background: #ffffff;
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 22px 60px -40px rgba(75, 23, 106, 0.45);
  border: 1px solid rgba(75, 23, 106, 0.08);
}

h2 {
  margin: 0 0 0.75rem 0;
  color: #4b176a;
}

.lead {
  margin: 0 0 1.5rem 0;
  font-size: 1rem;
  color: #5d2a80;
}

form {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.file-input {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.6rem;
  border-radius: 999px;
  background: #f6effc;
  color: #4b176a;
  border: 1px solid rgba(75, 23, 106, 0.15);
  cursor: pointer;
  font-weight: 600;
}

.file-input input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.2s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

#submit-btn {
  background: #4b176a;
  color: #ffffff;
  box-shadow: 0 14px 34px -20px rgba(75, 23, 106, 0.75);
}

#submit-btn:hover:not(:disabled),
.actions button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.actions button {
  background: #764b9f;
  color: #ffffff;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  transition: all 0.3s ease;
}

/* Download buttons - enhanced styling when ready */
.download-ready {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
  color: white !important;
  box-shadow: 0 8px 25px -8px rgba(40, 167, 69, 0.5) !important;
  border: 2px solid rgba(40, 167, 69, 0.3) !important;
  font-weight: 700 !important;
  animation: downloadPulse 2s ease-in-out infinite;
}

.download-ready:hover:not(:disabled) {
  background: linear-gradient(135deg, #218838 0%, #1ba085 100%) !important;
  transform: translateY(-3px) !important;
  box-shadow: 0 12px 35px -10px rgba(40, 167, 69, 0.6) !important;
}

@keyframes downloadPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

/* Disabled state override for download buttons */
.actions button:disabled {
  background: #6c757d !important;
  color: #ffffff !important;
  opacity: 0.4 !important;
  box-shadow: none !important;
  border: 1px solid rgba(108, 117, 125, 0.2) !important;
  animation: none !important;
}

.app-header .logout-button {
  background: transparent;
  color: white;
  border: 1px solid white;
  padding: 0.5rem 1.2rem;
  font-size: 0.875rem;
}

.app-header .logout-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  transform: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.actions {
  display: inline-flex;
  gap: 0.6rem;
}

.result {
  background: #30103f;
  color: #f1e7ff;
  padding: 1.5rem;
  border-radius: 12px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid rgba(241, 231, 255, 0.12);
}

.hint {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: #6d4f8b;
}

.error-banner {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: #ffe6f1;
  color: #651c43;
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  border: 1px solid rgba(101, 28, 67, 0.2);
}

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 1rem;
}

.login-box {
  background: #ffffff;
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 22px 60px -40px rgba(75, 23, 106, 0.45);
  border: 1px solid rgba(75, 23, 106, 0.08);
  width: 100%;
  max-width: 400px;
}

.login-box h1 {
  text-align: center;
  margin-bottom: 2rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  color: #4b176a;
  font-weight: 600;
}

.form-group input {
  padding: 0.75rem 1rem;
  border: 1px solid rgba(75, 23, 106, 0.2);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #4b176a;
}

.login-button {
  background: #4b176a;
  color: #ffffff;
  padding: 1rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.login-button:hover:not(:disabled) {
  background: #5d2a80;
  transform: translateY(-2px);
}

.login-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.error-message {
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  text-align: center;
}

.error-state {
  color: #d32f2f;
  background: #ffebee;
}

.success-state {
  color: #2e7d32;
  background: #e8f5e8;
}

.login-subtitle {
  text-align: center;
  color: #6d4f8b;
  margin-bottom: 2rem;
}

@media (max-width: 640px) {
  body {
    padding: 1rem;
  }

  form {
    flex-direction: column;
    align-items: stretch;
  }

  .file-input,
  button {
    width: 100%;
    justify-content: center;
  }
}
