/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Topbar ===== */
.topbar {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #ffffff;
  padding: 20px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.topbar h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.topbar p {
  font-size: 13px;
  opacity: 0.85;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== Buttons ===== */
button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  transition: all 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

button.primary {
  background: #2563eb;
  color: #ffffff;
}

button.primary:hover {
  background: #1d4ed8;
}

button.accent {
  background: #f59e0b;
  color: #ffffff;
}

button.accent:hover {
  background: #d97706;
}

button.link {
  background: none;
  color: #2563eb;
  padding: 4px 8px;
  font-size: 13px;
  box-shadow: none;
}

button.link:hover {
  text-decoration: underline;
  transform: none;
  box-shadow: none;
}

button.danger-text {
  color: #ef4444;
}

/* ===== Container ===== */
.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ===== Message ===== */
.message {
  padding: 12px 20px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  display: none;
}

.message.info {
  display: block;
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.message.success {
  display: block;
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.message.error {
  display: block;
  background: #fef2f2;
  color: #ef4444;
  border: 1px solid #fecaca;
}

.message.warning {
  display: block;
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}

/* ===== Card Grid ===== */
.grid.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: #ffffff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid #e5e7eb;
  text-align: center;
}

.card span {
  display: block;
  font-size: 13px;
  color: #64748b;
  margin-bottom: 8px;
}

.card strong {
  display: block;
  font-size: 26px;
  font-weight: 800;
  color: #1e293b;
}

/* ===== Panel ===== */
.panel {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid #e5e7eb;
}

.panel-title {
  margin-bottom: 16px;
}

.panel-title h2 {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
}

.panel-title span {
  font-size: 13px;
  color: #64748b;
}

/* ===== Forms ===== */
.form {
  margin-bottom: 16px;
}

.form input {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form input {
  flex: 1;
  min-width: 200px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.grid-form button {
  grid-column: 1 / -1;
}

/* ===== Tables ===== */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}

tbody tr:hover {
  background: #f8fafc;
}

td.empty {
  text-align: center;
  color: #94a3b8;
  padding: 32px 14px;
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge.success {
  background: #dcfce7;
  color: #16a34a;
}

.badge.warning {
  background: #fef3c7;
  color: #d97706;
}

.badge.danger {
  background: #fee2e2;
  color: #ef4444;
}

.badge.normal {
  background: #f1f5f9;
  color: #64748b;
}

/* ===== Colors ===== */
.up {
  color: #ef4444;
  font-weight: 600;
}

.down {
  color: #16a34a;
  font-weight: 600;
}

/* ===== Quote Card ===== */
.quote-card {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 20px;
  margin-top: 16px;
}

.quote-card h3 {
  font-size: 18px;
  color: #1e293b;
  margin-bottom: 8px;
}

.quote-card h3 span {
  color: #64748b;
  font-size: 14px;
  margin-left: 8px;
}

.quote-price {
  font-size: 36px;
  font-weight: 800;
  color: #2563eb;
  margin-bottom: 16px;
}

.quote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.quote-grid span {
  font-size: 14px;
  color: #475569;
}

.quote-grid b {
  font-weight: 700;
}

/* ===== Analysis Card ===== */
#technicalChart {
  width: 100%;
  margin-top: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #ffffff;
}

.analysis-card {
  margin-top: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.analysis-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.analysis-head h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.analysis-head h3 span {
  color: #64748b;
  font-size: 14px;
  margin-left: 8px;
}

.analysis-head p {
  margin: 0;
  color: #64748b;
}

.score {
  min-width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #eff6ff;
  color: #2563eb;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  font-weight: 800;
  border: 1px solid #bfdbfe;
}

.score small {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.metric-grid span {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  color: #334155;
  font-size: 13px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 12px;
}

.two-col h4 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #475569;
}

.two-col ul {
  margin: 0;
  padding-left: 18px;
  color: #475569;
  font-size: 13px;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: #94a3b8;
}

/* ===== Responsive ===== */
@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 20px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .grid.cards {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .card strong {
    font-size: 22px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .analysis-head {
    align-items: flex-start;
  }

  .inline-form {
    flex-direction: column;
  }

  .inline-form input {
    min-width: 100%;
  }

  .quote-price {
    font-size: 28px;
  }
}
