/* A-Share Short-Term Stock System - Custom CSS */
:root {
  --primary: #1976d2;
  --primary-dark: #0d47a1;
  --primary-light: #e3f2fd;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  /* A-share color convention: Red=Up, Green=Down */
  --up-red: #e53935;
  --up-bg: #ffebee;
  --down-green: #2e7d32;
  --down-bg: #e8f5e9;

  /* Market States */
  --state-attack: #d32f2f;
  --state-normal: #1976d2;
  --state-defense: #f57c00;
  --state-empty: #7b1fa2;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Nav */
.navbar {
  background-color: #0f172a;
  color: #f8fafc;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
}

.nav-links a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.925rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: #ffffff;
  background-color: #1e293b;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.btn-logout {
  color: #f87171;
  text-decoration: none;
  border: 1px solid #7f1d1d;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  transition: background-color 0.2s;
}

.btn-logout:hover {
  background-color: #7f1d1d;
  color: #fff;
}

/* Container */
.container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fafafa;
}

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

.card-body {
  padding: 1.25rem;
}

/* Market State Badges */
.state-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.state-进攻 { background-color: #ffebee; color: var(--state-attack); border: 1px solid #ffcdd2; }
.state-正常 { background-color: #e3f2fd; color: var(--state-normal); border: 1px solid #bbdefb; }
.state-防守 { background-color: #fff3e0; color: var(--state-defense); border: 1px solid #ffe0b2; }
.state-空仓观望 { background-color: #f3e5f5; color: var(--state-empty); border: 1px solid #e1bee7; }

/* Grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

/* Stat Box */
.stat-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.stat-value {
  font-size: 1.45rem;
  font-weight: 700;
  margin-top: 0.25rem;
  color: var(--text-main);
}

.stat-value.up { color: var(--up-red); }
.stat-value.down { color: var(--down-green); }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover { background-color: var(--primary-dark); }

.btn-outline {
  border-color: var(--border);
  background: white;
  color: var(--text-main);
}
.btn-outline:hover { background-color: #f1f5f9; }

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.form-control {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text-main);
  background-color: white;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}

.tab-item {
  padding: 0.5rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-item:hover { color: var(--primary); }
.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.table tbody tr:hover {
  background-color: #f8fafc;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.25rem;
  margin-bottom: 0.2rem;
}

.badge-primary { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.badge-success { background: var(--up-bg); color: var(--up-red); border: 1px solid #ffcdd2; }
.badge-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

.tag-industry {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

/* Stock text color */
.val-up { color: var(--up-red); font-weight: 600; }
.val-down { color: var(--down-green); font-weight: 600; }

/* K-Line chart container */
.chart-container {
  width: 100%;
  height: 480px;
}

/* Footer */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: #ffffff;
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.825rem;
}

.disclaimer-badge {
  display: inline-block;
  background-color: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

/* Login Page */
.login-wrap {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.form-group input {
  width: 100%;
}
