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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
  font-size: 16px;
}

/* Login page styles */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-form {
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

.login-form h2 {
  margin-bottom: 30px;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

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

button[type="submit"], .btn {
  width: 100%;
  padding: 12px;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s;
}

button[type="submit"]:hover, .btn:hover {
  background-color: #45a049;
}

.error-message {
  color: #d32f2f;
  background-color: #ffebee;
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 20px;
  display: none;
}

.error-message:not(:empty) {
  display: block;
}

/* Main app styles */
.container {
  max-width: 100%;
  margin: 0 auto;
  padding: 10px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: white;
  padding: 8px 12px;
  margin-bottom: 10px;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-title {
  font-size: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.toolbar-search {
  flex: 1;
  display: flex;
  gap: 6px;
  min-width: 0;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 12px 0;
  padding: 10px 20px;
  font-size: 15px;
  color: #555;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.search-box {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 15px;
}

.search-box:focus {
  outline: none;
  border-color: #4CAF50;
}

.records {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  transition: opacity 0.15s ease;
}

@media (min-width: 1250px) {
  .records {
    grid-template-columns: 1fr 1fr;
  }
}

.records.fading {
  opacity: 0;
}

.record {
  animation: fadeIn 0.3s ease;
}

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

.record {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.record-header {
  background: #f5f5f5;
  padding: 10px 20px;
  border-bottom: none;
  font-size: 13px;
  color: #888;
  font-weight: 500;
}

.record-meta {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 6px 20px 10px;
  border-bottom: 1px solid #eee;
  overflow: hidden;
}

.meta-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.meta-time {
  background: #e8f0fe;
  color: #1a56db;
}

.meta-ago {
  background: #f0f0f0;
  color: #666;
}

.meta-pool {
  background: #e6f4ea;
  color: #137333;
  flex: 1 1 0;
  min-width: 60px;
}

.meta-pool:hover {
  background: #c8e6c9;
}

.meta-project {
  background: #fef3e0;
  color: #b45309;
  flex: 0 1 auto;
  min-width: 60px;
  max-width: 200px;
}

.meta-project:hover {
  background: #ffe0b2;
}

.search-summary {
  margin: 12px auto;
  padding: 10px 20px;
  font-size: 15px;
  color: #444;
  font-weight: 400;
  line-height: 1.6;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: opacity 0.3s ease;
  min-height: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}

.pool-filter-warning {
  margin-top: 6px;
  padding: 8px 12px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 6px;
  font-size: 13px;
  color: #795548;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pool-filter-warning-text {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pool-filter-warning-name {
  font-weight: 600;
}

.pool-filter-reset-btn {
  flex-shrink: 0;
  width: auto;
  padding: 4px 12px;
  font-size: 12px;
  background: #fff;
  color: #795548;
  border: 1px solid #d7ccc8;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.pool-filter-reset-btn:hover {
  background: #efebe9;
}

.record-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 20px;
}

.record-section {
  min-height: 100px;
  max-width: 50vw;
  overflow-wrap: break-word;
  word-break: break-word;
}

.record-section h3 {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #4CAF50;
  font-size: 20px;
}

.input-item {
  margin-bottom: 20px;
}

.input-key {
  font-weight: bold;
  margin-bottom: 8px;
  color: #4CAF50;
  font-size: 17px;
}

.input-value {
  padding: 12px;
  background: #f9f9f9;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.input-value pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  font-family: inherit;
  font-size: inherit;
}

.html-content {
  padding: 12px;
  background: #f9f9f9;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word;
  word-break: break-word;
}

.output-content {
  padding: 12px;
  background: #f9f9f9;
  border-radius: 4px;
  font-size: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.output-content pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  font-family: inherit;
  font-size: inherit;
}

.output-list {
  list-style: none;
  padding-left: 0;
}

.output-list li {
  padding: 10px 0;
  border-bottom: 1px solid #eee;
  font-size: 16px;
}

.output-list li:last-child {
  border-bottom: none;
}

.output-list .key {
  font-weight: 600;
  color: #333;
  display: inline-block;
  min-width: 250px;
}

.output-list .value {
  color: #666;
  word-break: break-word;
}

.output-list .value.yes {
  color: #4CAF50;
}

.output-list .value.no {
  color: #999;
}

.output-list ul {
  list-style: none;
  padding-left: 20px;
  margin-top: 5px;
}

/* Vertical layout for search results */
.record-content--vertical {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

.record-content--vertical .record-snippets {
  overflow-wrap: break-word;
  word-break: break-word;
}

.record-content--vertical .record-snippets h3 {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid #2196F3;
  font-size: 16px;
  color: #555;
}

.record-content--vertical .record-output-full {
  overflow-wrap: break-word;
  word-break: break-word;
}

.record-content--vertical .record-output-full h3 {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #4CAF50;
  font-size: 18px;
}

/* Collapsible input block */
.record-section-collapsible {
  position: relative;
}

.record-section-collapsible h3 {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #4CAF50;
  font-size: 18px;
}

.collapsible-body {
  max-height: 180px;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.record-section-collapsible.expanded .collapsible-body {
  max-height: none;
}

.collapsible-fade-outer {
  position: relative;
  z-index: 1;
  margin-top: -80px;
  height: 80px;
  background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
  pointer-events: none;
  transition: opacity 0.3s ease, margin-top 0.3s ease, height 0.3s ease;
}

.record-section-collapsible.expanded .collapsible-fade-outer {
  opacity: 0;
  margin-top: 0;
  height: 0;
}

.collapsible-toggle {
  display: block;
  margin: 8px auto 0;
  padding: 5px 20px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 16px;
  color: #555;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  width: auto;
}

.collapsible-toggle:hover {
  background: #e8e8e8;
}

.record-section-collapsible.no-overflow .collapsible-body {
  max-height: none;
}

.record-section-collapsible.no-overflow .collapsible-fade-outer,
.record-section-collapsible.no-overflow .collapsible-toggle {
  display: none;
}

/* Snippets */
.snippet {
  display: block;
  padding: 8px 12px;
  margin-bottom: 6px;
  background: #f8f9fa;
  border-left: 3px solid #2196F3;
  border-radius: 0 4px 4px 0;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: #555;
}

.snippet-match {
  background: #fff176;
  color: #333;
  font-weight: 600;
  padding: 1px 2px;
  border-radius: 2px;
}

.snippet-context {
  color: #666;
}

.snippet-ellipsis {
  color: #aaa;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 0 2px;
}

.snippet-empty {
  color: #999;
  font-style: italic;
  padding: 8px 0;
}

.highlight {
  background-color: #ffeb3b;
  padding: 2px 0;
  font-weight: 500;
}

/* Blur placeholder for lazy-loaded count */
.summary-line {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 24px;
}

.summary-count {
  opacity: 0;
  transition: opacity 0.3s ease;
  text-align: center;
}

.summary-count.visible {
  opacity: 1;
}

.loading, .search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  color: #888;
  font-size: 15px;
  animation: pulse-text 1.5s ease-in-out infinite;
  transition: opacity 0.1s ease;
}

.loading.fade-out {
  opacity: 0;
}

.search-loading {
  padding: 0;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid #ddd;
  border-top-color: #4CAF50;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.no-results {
  text-align: center;
  padding: 40px;
  color: #999;
}

.logout-btn {
  background-color: #f44336;
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
  flex-shrink: 0;
  white-space: nowrap;
}

.logout-btn:hover {
  background-color: #d32f2f;
}

/* Tabs */
.nav-tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  padding: 8px 20px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f5f5f5;
  color: #666;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  width: auto;
}

.tab-btn:hover {
  background: #e8e8e8;
}

.tab-btn.active {
  background: #4CAF50;
  color: white;
  border-color: #4CAF50;
}

.tab-content {
  display: none;
}

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

.pool-id-box {
  width: 220px;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 15px;
  flex-shrink: 0;
}

.pool-id-box:focus {
  outline: none;
  border-color: #4CAF50;
}

/* Chart */
.chart-section {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-bottom: 20px;
}

.chart-section h2 {
  font-size: 18px;
  color: #333;
  margin-bottom: 15px;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 400px;
}

/* Statistics tab */
.stats-header {
  margin-bottom: 15px;
}

.stats-header h2 {
  font-size: 20px;
  color: #333;
}

.top-pools-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.top-pools-table {
  width: 100%;
  border-collapse: collapse;
}

.top-pools-table th,
.top-pools-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.top-pools-table th {
  background: #f5f5f5;
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.top-pools-table td {
  font-size: 15px;
}

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

.top-pools-table tr:hover {
  background: #f9f9f9;
}

.pool-link {
  color: #4CAF50;
  text-decoration: none;
  cursor: pointer;
}

.pool-link:hover {
  text-decoration: underline;
}

.pool-new-count {
  font-weight: 600;
  color: #4CAF50;
}

.pool-name-label {
  display: inline;
  margin-left: 6px;
  color: #555;
  font-weight: normal;
  font-size: 13px;
}

.pool-project-name {
  display: inline;
  margin-left: 4px;
  color: #888;
  font-weight: normal;
  font-size: 12px;
}

@media (max-width: 768px) {
  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar-title {
    font-size: 18px;
  }

  .toolbar-search {
    order: 10;
    flex-basis: 100%;
  }

  .record-content {
    grid-template-columns: 1fr;
  }

  .stats {
    flex-direction: column;
    gap: 4px;
    text-align: center;
  }

  .pool-id-box {
    width: 100%;
  }
}

