/* ===== CSS Variables ===== */
:root {
  --bg:          #0f1117;
  --bg-card:     #1a1d27;
  --bg-input:    #12151f;
  --border:      #2a2d3e;
  --accent:      #4ade80;
  --accent-dim:  #166534;
  --accent-blue: #60a5fa;
  --accent-red:  #f87171;
  --text:        #e2e8f0;
  --text-muted:  #64748b;
  --font:        'Inter', system-ui, sans-serif;
  --radius:      10px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent-blue); text-decoration: none; }

/* ===== Header ===== */
header {
  background: linear-gradient(135deg, #0d1b2a 0%, #1a2744 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

.logo svg { width: 28px; height: 28px; }

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ===== Ad Banner ===== */
.ad-banner {
  background: linear-gradient(90deg, #1a1d27 0%, #1e2235 100%);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

.ad-banner .ad-label {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 0.6rem;
  color: var(--text-muted);
  opacity: 0.5;
}

/* Ad placeholder styling */
.ad-placeholder {
  width: 728px;
  max-width: 100%;
  height: 90px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  gap: 0.5rem;
}

.ad-rectangle {
  width: 300px;
  height: 250px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  gap: 0.4rem;
  margin: 1rem auto;
}

/* ===== Layout ===== */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.left-col { display: flex; flex-direction: column; gap: 1.5rem; }
.right-col { display: flex; flex-direction: column; gap: 1.5rem; }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

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

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title svg { color: var(--accent); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-primary { background: var(--accent); color: #0a0f0a; }
.btn-primary:hover { background: #86efac; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger { background: transparent; border: 1px solid #7f1d1d; color: var(--accent-red); }
.btn-danger:hover { background: #450a0a; }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.2rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  transition: color 0.15s;
}
.btn-icon:hover { color: var(--accent-blue); }

/* ===== Forms ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

label {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

input, select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.9rem;
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
  font-family: var(--font);
}

input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-muted); }

select option { background: var(--bg-card); }

.input-with-suffix {
  position: relative;
}
.input-with-suffix input { padding-right: 2.2rem; }
.input-suffix {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

/* ===== Info Button ===== */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--accent-blue);
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  line-height: 1;
}
.info-btn:hover { background: #1e3a5f; }

/* ===== Account List ===== */
.account-list { display: flex; flex-direction: column; gap: 0.6rem; }

.account-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  transition: border-color 0.15s;
}
.account-item:hover { border-color: var(--border); }

.account-item-info { flex: 1; min-width: 0; }
.account-nickname { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-meta { font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 1rem; flex-wrap: wrap; }
.account-type-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--accent);
  white-space: nowrap;
}
.account-value { font-size: 0.95rem; font-weight: 600; color: var(--accent); white-space: nowrap; }
.account-actions { display: flex; gap: 0.3rem; }

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

/* ===== Add Account Form ===== */
.add-form-wrap {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* ===== Config Grid ===== */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem 1rem;
}

/* ===== Chart Mode Selector ===== */
.chart-mode-selector {
  display: flex;
  gap: 0.3rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem;
  margin-bottom: 1.2rem;
}

.mode-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  white-space: nowrap;
}

.mode-btn:hover { color: var(--text); }

.mode-btn.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 6px rgba(0,0,0,0.35);
}

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

/* ===== Chart ===== */
.chart-wrap {
  position: relative;
  height: 380px;
}

.chart-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  text-align: center;
}

.stat-label { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0.3rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1.2rem; font-weight: 700; }
.stat-value.green  { color: var(--accent); }
.stat-value.blue   { color: var(--accent-blue); }
.stat-value.red    { color: var(--accent-red); }
.stat-value.yellow { color: #fbbf24; }

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 460px;
  width: 90%;
  box-shadow: var(--shadow);
  position: relative;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--accent-blue);
}

.modal-body { font-size: 0.88rem; color: var(--text-muted); line-height: 1.7; }
.modal-body strong { color: var(--text); }

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* ===== Save indicator ===== */
.save-indicator {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.3s;
}
.save-indicator.saving { color: #fbbf24; }
.save-indicator.saved  { color: var(--accent); }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font-size: 0.83rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .container { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
  .chart-stats { grid-template-columns: 1fr 1fr; }
  .ad-placeholder { width: 100%; }
}
