html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

* {
  box-sizing: border-box;
}

body {
  font-family: Montserrat, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100%;
  overflow: hidden;
}

.app-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 20px 30px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.header-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 15px;
}

.app-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

.app-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: #333;
  text-align: center;
}

.header-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.file-input-wrapper {
  display: flex;
  align-items: center;
}

.file-input-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: #667eea;
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(102, 126, 234, 0.3);
}

.file-input-label:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

.file-input-label:active {
  transform: translateY(0);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: #764ba2;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(118, 75, 162, 0.3);
}

.action-btn:hover {
  background: #5d3a7e;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(118, 75, 162, 0.4);
}

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

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid #e0e0e0;
  gap: 20px;
  flex-wrap: wrap;
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f5f5f5;
  border-radius: 8px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.search-wrapper:focus-within {
  border-color: #667eea;
  background: white;
}

.search-wrapper svg {
  color: #666;
  flex-shrink: 0;
}

.search-input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  width: 250px;
  color: #333;
}

.search-input::placeholder {
  color: #999;
}

.clear-btn {
  background: #ccc;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  transition: background 0.2s;
}

.clear-btn:hover {
  background: #999;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: #f0f0f0;
  color: #333;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.2s ease;
}

.toolbar-btn:hover {
  background: #e0e0e0;
  transform: translateY(-1px);
}

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

.toolbar-btn svg {
  flex-shrink: 0;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 8px 16px;
  background: #f0f0f0;
  border-radius: 8px;
  font-size: 14px;
}

.file-name-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-info #file-name {
  font-weight: 600;
  color: #333;
}

.file-name-input {
  padding: 4px 8px;
  border: 2px solid #667eea;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  background: white;
  min-width: 150px;
  outline: none;
}

.file-name-input:focus {
  border-color: #5568d3;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.rename-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
  opacity: 0.7;
}

.rename-btn:hover {
  background: #e0e0e0;
  color: #333;
  opacity: 1;
}

.file-info #file-stats {
  color: #666;
  font-size: 13px;
}

.drop-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px;
  border: 3px dashed #ccc;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: all 0.3s ease;
}

.drop-zone:hover {
  border-color: #667eea;
  background: rgba(255, 255, 255, 0.95);
}

.drop-zone.drag-over {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.1);
  transform: scale(1.02);
}

.drop-zone-content {
  text-align: center;
  color: #666;
  padding: 40px;
}

.drop-zone-content svg {
  margin-bottom: 20px;
  color: #667eea;
  opacity: 0.7;
}

.drop-zone-content h2 {
  margin: 0 0 10px 0;
  font-size: 24px;
  color: #333;
}

.drop-zone-content p {
  margin: 0;
  font-size: 16px;
  color: #666;
}

.loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: white;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading p {
  font-size: 18px;
  font-weight: 500;
}

.error {
  margin: 20px;
  padding: 16px 24px;
  background: #fee;
  border: 2px solid #fcc;
  border-radius: 8px;
  color: #c33;
  font-weight: 500;
  text-align: center;
}

.table-container {
  flex: 1;
  margin: 0 20px 20px 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  min-height: 0;
}

#handsontable-container.handsontable {
  height: 100%;
}

.sponsors {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
}

.sponsors a {
  margin: 0;
  display: inline-flex;
  flex-direction: column;
  border-radius: 5px;
  text-decoration: none;
  max-width: calc(300px + 2*20px + 2*3px);
}

.sponsors a:hover {
  text-decoration: underline;
}

.sponsors a span {
  font-size: 14px;
  margin-bottom: 18px;
  text-align: center;
}

.sponsors div {
  width: 100%;
  text-align: center;
}

.place-your-ad-here {
  display: inline-block;
  border: 3px solid #126BCF;
  border-radius: 5px;
  color: #126BCF;
  font-weight: bold;
  padding: 10px 25px;
  text-align: center;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 0;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  color: #333;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

.modal-body {
  padding: 24px;
}

.url-input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 15px;
  transition: border-color 0.3s;
}

.url-input:focus {
  outline: none;
  border-color: #667eea;
}

.url-error {
  color: #c33;
  font-size: 13px;
  margin-top: 10px;
  padding: 8px;
  background: #fee;
  border-radius: 6px;
}

/* Statistics Panel */
.stats-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  z-index: 999;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.3s ease;
  overflow-y: auto;
}

/* Chart Analysis Panel */
.chart-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 600px;
  max-width: 90vw;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  z-index: 999;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.3s ease;
  overflow-y: auto;
}

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

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f9fa;
  position: sticky;
  top: 0;
  z-index: 10;
}

.stats-header h3 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.stats-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.stats-close:hover {
  background: #e0e0e0;
  color: #333;
}

.stats-content {
  padding: 20px;
}

.stats-grid {
  display: grid;
  gap: 15px;
}

.stat-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 15px;
  border-left: 4px solid #667eea;
}

.stat-card h4 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: #333;
  font-weight: 600;
}

.stat-item {
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
  line-height: 1.6;
}

.stat-item strong {
  color: #333;
  margin-right: 8px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f9fa;
  position: sticky;
  top: 0;
  z-index: 10;
}

.chart-header h3 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.chart-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.chart-close:hover {
  background: #e0e0e0;
  color: #333;
}

.chart-controls {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  background: #fafafa;
}

.chart-control-group {
  margin-bottom: 20px;
}

.chart-control-group:last-child {
  margin-bottom: 0;
}

.chart-control-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.chart-select {
  width: 100%;
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  background: white;
  color: #333;
  cursor: pointer;
  transition: border-color 0.3s;
}

.chart-select:focus {
  outline: none;
  border-color: #667eea;
}

.generate-chart-btn,
.clear-chart-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: 10px;
}

.generate-chart-btn {
  background: #667eea;
  color: white;
}

.generate-chart-btn:hover {
  background: #5568d3;
  transform: translateY(-1px);
}

.clear-chart-btn {
  background: #f0f0f0;
  color: #333;
}

.clear-chart-btn:hover {
  background: #e0e0e0;
}

.series-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}

.series-selector select {
  flex: 1;
}

.remove-series-btn {
  background: #ff4444;
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.remove-series-btn:hover {
  background: #cc0000;
}

.add-series-btn {
  padding: 8px 16px;
  background: #f0f0f0;
  color: #333;
  border: 2px dashed #ccc;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.add-series-btn:hover {
  background: #e0e0e0;
  border-color: #999;
}

.chart-container-wrapper {
  flex: 1;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  background: white;
}

#chart-canvas {
  max-width: 100%;
  max-height: 100%;
}

@media (max-width: 768px) {
  .app-header {
    padding: 15px 20px;
  }

  .app-header h1 {
    font-size: 22px;
  }

  .app-logo {
    width: 32px;
    height: 32px;
  }

  .header-title {
    gap: 8px;
  }

  .header-controls {
    flex-direction: column;
    gap: 10px;
  }

  .file-info {
    flex-direction: column;
    gap: 5px;
    text-align: center;
  }

  .toolbar {
    padding: 12px 15px;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-section {
    width: 100%;
  }

  .search-input {
    width: 100%;
    flex: 1;
  }

  .toolbar-btn {
    flex: 1;
    justify-content: center;
    font-size: 12px;
    padding: 8px 12px;
  }

  .drop-zone-content {
    padding: 20px;
  }

  .drop-zone-content h2 {
    font-size: 20px;
  }

  .table-container {
    margin: 0 10px 10px 10px;
  }

  .sponsors {
    position: relative;
    top: 0;
    right: 0;
    margin: 10px;
  }

  .stats-panel {
    width: 100%;
    max-width: 100vw;
  }

  .chart-panel {
    width: 100%;
    max-width: 100vw;
  }

  .chart-container-wrapper {
    min-height: 300px;
  }

  .modal-content {
    width: 95%;
    margin: 20px;
  }
}

/* AdSense Styles */
.ads-container {
  width: 100%;
  margin: 20px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100px;
}

.ads-top {
  margin-top: 0;
  margin-bottom: 20px;
}

.ads-in-content {
  margin: 30px 20px;
}

.ads-bottom {
  margin-top: 30px;
  margin-bottom: 0;
}

.ads-container ins {
  display: block;
  text-align: center;
}

/* Responsive AdSense */
@media (max-width: 768px) {
  .ads-container {
    margin: 15px 10px;
    min-height: 50px;
  }

  .ads-in-content {
    margin: 20px 10px;
  }
}
