/* ==========================================================================
   ONEKEY // TOKEN MONITOR - THEME STYLESHEET
   Aesthetics: Red-on-Black Terminal Dashboard
   ========================================================================== */

:root {
  --bg-color: #080808;
  --bg-card: #111111;
  --bg-card-hover: #161616;
  --bg-elevated: #181818;
  --bg-input: #0c0c0c;
  --border-subtle: #222222;
  --border-medium: #333333;
  --border-accent: #ff3030;
  --border-accent-dim: rgba(255, 48, 48, 0.35);

  --accent-red: #ff3030;
  --accent-red-hover: #ff4747;
  --accent-red-dim: rgba(255, 48, 48, 0.12);
  --accent-red-glow: none;
  --accent-red-glow-strong: none;

  --text-main: #f5f5f5;
  --text-secondary: #888888;
  --text-muted: #555555;

  --status-active-color: #ff3030;
  --status-active-bg: rgba(255, 48, 48, 0.12);
  --status-active-border: #ff3030;

  --status-rate-color: #ffaa00;
  --status-rate-bg: rgba(255, 170, 0, 0.12);
  --status-rate-border: #ffaa00;

  --status-error-color: #e04444;
  --status-error-bg: rgba(224, 68, 68, 0.12);
  --status-error-border: #802222;

  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', Consolas, Menlo, Monaco, monospace;
}

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

html {
  font-size: 15px;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-color);
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 30px 30px, 30px 30px;
  padding: 24px 16px;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-red);
}

/* Container */
.terminal-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ==========================================================================
   Header Section
   ========================================================================== */

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 18px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-red);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.terminal-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.pulse-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-red);
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

.terminal-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-main);
  line-height: 1.2;
}

.accent-slash {
  color: var(--accent-red);
}

.terminal-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.header-counters {
  display: flex;
  gap: 20px;
}

.counter-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  border-left: 1px solid var(--border-subtle);
  padding-left: 20px;
}

.counter-label {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.counter-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
  margin-top: 2px;
}

.counter-val.accent-val {
  color: var(--accent-red);
}

/* ==========================================================================
   Terminal Card / Input Section
   ========================================================================== */

.terminal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 20px 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

.card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-prompt {
  color: var(--accent-red);
  font-weight: 800;
  font-size: 1.1rem;
}

.card-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-main);
}

.key-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  border-radius: 2px;
  letter-spacing: 0.05em;
}

.key-badge.has-keys {
  border-color: var(--border-accent-dim);
  color: var(--accent-red);
  background: var(--accent-red-dim);
}

.textarea-wrapper {
  position: relative;
  width: 100%;
}

textarea#keysInput {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.5;
  padding: 14px 16px;
  resize: vertical;
  min-height: 120px;
  border-radius: 0;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea#keysInput:focus {
  border-color: var(--accent-red);
}

textarea#keysInput::placeholder {
  color: var(--text-muted);
}

.input-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
}

.action-buttons-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-info {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 10px 20px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-primary {
  background-color: var(--accent-red);
  color: #ffffff;
  border-color: var(--accent-red);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-red-hover);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-secondary {
  background-color: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border-medium);
}

.btn-secondary:hover:not(:disabled) {
  color: var(--text-main);
  border-color: var(--text-secondary);
}

.btn-outline {
  background-color: transparent;
  color: var(--text-main);
  border-color: var(--border-medium);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--accent-red);
  color: var(--accent-red);
  background: var(--accent-red-dim);
}

.btn-sm {
  font-size: 0.72rem;
  padding: 6px 12px;
}

.btn-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

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

.btn.loading .btn-spinner {
  display: inline-block;
}

/* Batch Progress Bar */
.batch-progress-wrapper {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-subtle);
}

.batch-progress-wrapper.active {
  display: flex;
}

.batch-progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--accent-red);
  font-weight: 600;
}

.batch-progress-track {
  width: 100%;
  height: 6px;
  background-color: var(--border-subtle);
  overflow: hidden;
}

.batch-progress-fill {
  height: 100%;
  width: 0%;
  background-color: var(--accent-red);
  transition: width 0.25s ease-out;
}

/* Alert Banner */
.alert-banner {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(255, 48, 48, 0.1);
  border: 1px solid var(--accent-red);
  color: var(--text-main);
  font-size: 0.82rem;
}

.alert-banner.active {
  display: flex;
}

.alert-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--accent-red);
  color: #fff;
  font-weight: 800;
  border-radius: 50%;
}

/* ==========================================================================
   Dashboard Summary Section
   ========================================================================== */

.summary-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.summary-card:hover {
  border-color: var(--border-medium);
}

.summary-card.highlight-card {
  border-color: var(--accent-red);
  background: var(--bg-card);
}

.summary-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.summary-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 6px;
  line-height: 1.2;
}

.summary-value.accent-text {
  color: var(--accent-red);
}

.summary-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Overall Portfolio Progress Bar */
.overall-progress-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 14px 20px;
}

.overall-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.overall-progress-percentage {
  color: var(--accent-red);
  font-size: 0.85rem;
  font-weight: 800;
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background-color: var(--border-subtle);
  border-radius: 1px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--accent-red);
  transition: width 0.3s ease-out;
}

/* ==========================================================================
   Results Toolbar
   ========================================================================== */

.results-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.results-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.results-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.results-title {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-main);
}

.last-checked {
  font-size: 0.72rem;
  color: var(--text-secondary);
  border-left: 1px solid var(--border-subtle);
  padding-left: 16px;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-pills {
  display: flex;
  gap: 6px;
}

.filter-pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  color: var(--text-main);
  border-color: var(--border-medium);
}

.filter-pill.active {
  background: var(--accent-red-dim);
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.utility-buttons {
  display: flex;
  gap: 8px;
}

/* ==========================================================================
   Account Cards Grid
   ========================================================================== */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 16px;
}

.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.account-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.account-card.active-account {
  border-top: 2px solid var(--accent-red);
}

.account-card.active-account:hover {
  border-color: var(--accent-red);
  border-top-color: var(--accent-red);
}

.account-card.rate-limited {
  border-top: 2px solid var(--status-rate-color);
}

.account-card.error-card {
  border-top: 2px solid var(--status-error-color);
  opacity: 0.9;
}

/* Card Top Section */
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.key-identifier {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.05em;
}

.key-index {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.status-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 2px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-badge.status-active {
  color: var(--status-active-color);
  background: var(--status-active-bg);
  border-color: var(--status-active-border);
}

.status-badge.status-ratelimited {
  color: var(--status-rate-color);
  background: var(--status-rate-bg);
  border-color: var(--status-rate-border);
}

.status-badge.status-error {
  color: var(--status-error-color);
  background: var(--status-error-bg);
  border-color: var(--status-error-border);
}

/* Card Main Statistics */
.card-stats {
  display: flex;
  flex-direction: column;
}

.stat-label-small {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  font-weight: 700;
}

.remaining-balance-large {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
  margin-top: 4px;
  letter-spacing: -0.02em;
}

.remaining-balance-large.accent-text {
  color: var(--accent-red);
}

.total-allocated-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Card Progress Bar */
.card-progress-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-progress-track {
  flex: 1;
  height: 8px;
  background-color: #1e1e1e;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.card-progress-fill {
  height: 100%;
  background-color: var(--accent-red);
  transition: width 0.3s ease;
}

.card-progress-pct {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-red);
  min-width: 44px;
  text-align: right;
}

.card-consumed-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.card-consumed-val {
  color: var(--text-main);
}

/* Card Error Block */
.card-error-box {
  background: rgba(255, 48, 48, 0.05);
  border: 1px solid var(--border-subtle);
  border-left: 2px solid var(--status-error-color);
  padding: 10px 12px;
  font-size: 0.74rem;
  line-height: 1.4;
}

.card-error-title {
  color: var(--status-error-color);
  font-weight: 700;
  margin-bottom: 2px;
}

.card-error-desc {
  color: var(--text-secondary);
}

.retry-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.68rem;
  padding: 2px 6px;
  background: var(--status-rate-bg);
  border: 1px solid var(--status-rate-border);
  color: var(--status-rate-color);
}

/* Card Loading State */
.account-card.loading-state {
  border-style: dashed;
}

.card-loading-content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 24px 0;
}

.card-loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 48, 48, 0.2);
  border-top-color: var(--accent-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.card-loading-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

/* Empty State / Initial Placeholder */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--border-subtle);
  color: var(--text-secondary);
}

.empty-state-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-state-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.terminal-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  padding: 16px 0;
  margin-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.footer-separator {
  color: var(--border-medium);
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--accent-red);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 10px 16px;
  border-left: 3px solid var(--accent-red);
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 900px) {
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 650px) {
  body {
    padding: 12px 8px;
  }

  .terminal-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .header-counters {
    width: 100%;
    justify-content: space-between;
  }

  .counter-box {
    align-items: flex-start;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    padding-left: 0;
    padding-top: 8px;
    flex: 1;
  }

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

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

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

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

  .filter-pills {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .utility-buttons {
    width: 100%;
  }

  .utility-buttons .btn {
    flex: 1;
  }
}

