/* ===== CSS Variables ===== */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-hover: #475569;
  --border-color: #334155;
  --border-light: #475569;

  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --accent-bg: #1e3a5f;

  --success: #22c55e;
  --success-bg: #166534;
  --warning: #f59e0b;
  --warning-bg: #451a03;
  --danger: #ef4444;
  --danger-bg: #450a0a;
  --info: #60a5fa;

  --sidebar-width: 240px;
  --sidebar-collapsed: 60px;
  --header-height: 56px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

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

a:hover {
  color: var(--accent-hover);
}

img, svg {
  max-width: 100%;
  display: block;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bg-hover);
}

/* ===== Layout ===== */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition-slow), width var(--transition-slow);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  height: var(--header-height);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--bg-primary);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  margin: 2px 0;
}

.sidebar-nav a:hover {
  color: var(--text-primary);
  background: rgba(56, 189, 248, 0.08);
}

.sidebar-nav a.active {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
  border-left-color: var(--accent);
}

.sidebar-nav a .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-nav a .nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

.sidebar-nav a .nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar-footer button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  font-family: var(--font-sans);
}

.sidebar-footer button:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
}

.sidebar-footer button .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer button .nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

/* ===== Top Header ===== */
.top-header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.hamburger {
  display: none;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.hamburger:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hamburger svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.top-header-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.top-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-header-right .datetime {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ===== Page Content ===== */
.page-content {
  padding: 1.5rem;
  max-width: 1440px;
  margin: 0 auto;
}

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

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

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

.card-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title .card-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

.card-body {
  color: var(--text-primary);
}

.card.clickable {
  cursor: pointer;
}

.card.clickable:hover {
  border-color: var(--accent);
}

/* ===== Grid Layouts ===== */
.grid {
  display: grid;
  gap: 1.25rem;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* ===== Stat Cards ===== */
.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: border-color var(--transition);
}

.stat-card:hover {
  border-color: var(--border-light);
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stat-label .stat-icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stat-value.sm {
  font-size: 1.1rem;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ===== Value Colors ===== */
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-accent { color: var(--accent) !important; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.badge-info {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.badge-neutral {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

/* ===== Run Type Badges ===== */
.run-type-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
}

.run-type-badge.daily_init {
  background: var(--accent-bg);
  color: var(--info);
}

.run-type-badge.signal_check {
  background: #1a3a2a;
  color: var(--success);
}

.run-type-badge.position_manage {
  background: #3b1f5e;
  color: #c084fc;
}

.run-type-badge.square_off {
  background: #5e2a1f;
  color: #fb923c;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #f87171;
}

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

.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.78rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

/* ===== Form Elements ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input,
.form-select {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: var(--font-sans);
  transition: border-color var(--transition);
  width: 100%;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
  cursor: pointer;
}

.form-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

textarea.form-input {
  min-height: 80px;
  resize: vertical;
}

/* ===== Forms Row ===== */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.form-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* ===== Search ===== */
.search-wrap {
  position: relative;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  max-height: 300px;
  overflow-y: auto;
  z-index: 50;
  display: none;
  box-shadow: var(--shadow-lg);
}

.search-results.active {
  display: block;
}

.search-result {
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
  transition: background var(--transition);
}

.search-result:hover {
  background: var(--bg-tertiary);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result .sym {
  color: var(--accent);
  font-weight: 600;
}

.search-result .meta {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.selected-instrument {
  background: var(--bg-tertiary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
  font-size: 0.82rem;
  display: none;
  align-items: center;
  justify-content: space-between;
}

.selected-instrument.active {
  display: flex;
}

.selected-instrument .key {
  color: var(--accent);
}

.selected-instrument .clear-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem;
  line-height: 1;
  transition: color var(--transition);
}

.selected-instrument .clear-btn:hover {
  color: #f87171;
}

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

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

.table th {
  text-align: left;
  padding: 0.65rem 1rem;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
}

.table td {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  color: var(--text-primary);
}

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

.table tr:hover td {
  background: rgba(56, 189, 248, 0.03);
}

.table td.mono {
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.table .json-preview {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.74rem;
  transition: color var(--transition);
  display: block;
}

.table .json-preview:hover {
  color: var(--accent);
}

/* ===== Filters Bar ===== */
.filters-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  background: var(--bg-secondary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.filters-bar .filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filters-bar .filter-group label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filters-bar .filter-group select,
.filters-bar .filter-group input {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font-sans);
}

.filters-bar .filter-group select:focus,
.filters-bar .filter-group input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== Summary Row ===== */
.summary-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.summary-item {
  background: var(--bg-secondary);
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.summary-item .label {
  color: var(--text-muted);
}

.summary-item .val {
  font-weight: 600;
  color: var(--accent);
}

/* ===== Status Bar (Strategy Page) ===== */
.status-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.status-item {
  background: var(--bg-secondary);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  flex: 1;
  min-width: 120px;
}

.status-item .label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-item .val {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 0.15rem;
}

/* ===== Pivot Points ===== */
.pivots-grid {
  background: var(--bg-primary);
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  margin-top: 0.65rem;
  font-size: 0.78rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.pivots-grid .label {
  color: var(--text-muted);
}

.pivots-grid .val {
  color: var(--text-primary);
  font-weight: 600;
}

/* ===== Position Detail ===== */
.position-detail {
  background: var(--bg-primary);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  margin-top: 0.65rem;
  font-size: 0.78rem;
}

.position-detail .row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.3rem;
  gap: 0.5rem;
}

.position-detail .row:last-child {
  margin-bottom: 0;
}

.position-detail .label {
  color: var(--text-muted);
}

.position-detail .val {
  font-weight: 600;
  color: var(--text-primary);
}

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

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.modal-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
  transition: color var(--transition);
}

.modal-close:hover {
  color: var(--danger);
}

.modal-body {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.6;
}

.modal-body pre {
  background: var(--bg-primary);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-family: var(--font-mono);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  max-height: 50vh;
  overflow-y: auto;
}

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

.toast {
  background: var(--success-bg);
  color: var(--success);
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.82rem;
  display: none;
  pointer-events: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--success);
  animation: toastIn 0.3s ease;
}

.toast.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.toast.show {
  display: block;
}

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

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.75rem;
  stroke: currentColor;
  stroke-width: 1;
  fill: none;
  opacity: 0.5;
}

.empty-state .empty-text {
  font-size: 0.88rem;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}

.pagination-controls {
  display: flex;
  gap: 0.5rem;
}

/* ===== Spinner ===== */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

.spinner-lg {
  width: 24px;
  height: 24px;
  border-width: 3px;
}

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
}

/* ===== Profile Row ===== */
.profile-row {
  display: flex;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.profile-row:last-child {
  border-bottom: none;
}

.profile-row .label {
  color: var(--text-muted);
  text-transform: capitalize;
}

.profile-row .value {
  color: var(--text-primary);
  font-weight: 500;
}

/* ===== Balance Display ===== */
.balance-display {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0.5rem 0;
}

.balance-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== Hidden Utility ===== */
.hidden {
  display: none !important;
}

/* ===== Refresh Indicator ===== */
.refresh-indicator {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ===== Section (Strategy Page) ===== */
.section {
  background: var(--bg-secondary);
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

/* ===== Login Page Specific ===== */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(56, 189, 248, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(56, 189, 248, 0.04) 0%, transparent 50%);
}

.login-card {
  background: var(--bg-secondary);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.login-card .login-logo {
  width: 48px;
  height: 48px;
  background: var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--bg-primary);
  margin: 0 auto 1rem;
}

.login-card h1 {
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
  text-align: center;
  color: var(--accent);
}

.login-card .login-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-card .error-msg {
  color: var(--danger);
  font-size: 0.82rem;
  margin-bottom: 0.8rem;
  text-align: center;
  display: none;
  padding: 0.5rem;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

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

/* Tablet */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-row-3 {
    grid-template-columns: 1fr 1fr;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .hamburger {
    display: flex;
  }

  .page-content {
    padding: 1rem;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filters-bar .filter-group {
    width: 100%;
  }

  .filters-bar .filter-group select,
  .filters-bar .filter-group input {
    width: 100%;
  }

  .status-bar {
    flex-direction: column;
  }

  .status-item {
    min-width: unset;
  }

  .top-header-title {
    font-size: 0.9rem;
  }

  .top-header-right .datetime {
    display: none;
  }

  .summary-row {
    gap: 0.5rem;
  }

  .summary-item {
    flex: 1;
    min-width: calc(50% - 0.5rem);
  }

  .login-card {
    margin: 1rem;
    padding: 1.75rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .pagination {
    flex-direction: column;
    gap: 0.5rem;
  }

  .stat-value {
    font-size: 1.3rem;
  }

  .balance-display {
    font-size: 1.5rem;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .page-content {
    padding: 0.75rem;
  }

  .card {
    padding: 1rem;
  }

  .section {
    padding: 1rem;
  }

  .summary-item {
    min-width: 100%;
  }

  .table th,
  .table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.7rem;
  }

  .table td.mono {
    font-size: 0.68rem;
  }

  .table .json-preview {
    max-width: 80px;
    font-size: 0.68rem;
  }

  /* Hide less critical columns on runs table */
  .table th:nth-child(5),
  .table td:nth-child(5),
  .table th:nth-child(6),
  .table td:nth-child(6),
  .table th:nth-child(9),
  .table td:nth-child(9) {
    display: none;
  }
}

/* Extra small mobile — hide even more columns */
@media (max-width: 380px) {
  .table th:nth-child(8),
  .table td:nth-child(8),
  .table th:nth-child(10),
  .table td:nth-child(10),
  .table th:nth-child(11),
  .table td:nth-child(11) {
    display: none;
  }

  .table th:nth-child(1),
  .table td:nth-child(1) {
    min-width: 70px;
  }
}

/* Scroll hint for table on mobile */
@media (max-width: 768px) {
  .table-wrap {
    position: relative;
  }

  .table-wrap::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, var(--bg-secondary));
    pointer-events: none;
    opacity: 1;
    transition: opacity var(--transition);
  }

  .table-wrap.scrolled-end::after {
    opacity: 0;
  }

  .filters-bar .btn {
    width: 100%;
    justify-content: center;
  }
}
