:root {
  --radius: 20px;
  --shadow: 0 16px 40px rgba(15, 23, 42, .08);
}

html[data-theme="light"] {
  --bg: #f8fafc;
  --panel: rgba(255, 255, 255, .92);
  --panel-2: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, .10);
  --primary: #2563eb;
  --primary-2: #06b6d4;
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
  --soft: #eef2ff;
  --soft-2: #f8fafc;
  --status-info-bg: rgba(37, 99, 235, .08);
  --status-info-bd: rgba(37, 99, 235, .18);
  --status-error-bg: rgba(220, 38, 38, .08);
  --status-error-bd: rgba(220, 38, 38, .18);
  --status-success-bg: rgba(22, 163, 74, .08);
  --status-success-bd: rgba(22, 163, 74, .18);
}

html[data-theme="dark"] {
  --bg: #020817;
  --panel: rgba(15, 23, 42, .88);
  --panel-2: rgba(15, 23, 42, .98);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, .16);
  --primary: #60a5fa;
  --primary-2: #22d3ee;
  --success: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --soft: rgba(30, 41, 59, .85);
  --soft-2: rgba(15, 23, 42, .75);
  --status-info-bg: rgba(96, 165, 250, .12);
  --status-info-bd: rgba(96, 165, 250, .22);
  --status-error-bg: rgba(239, 68, 68, .12);
  --status-error-bd: rgba(239, 68, 68, .22);
  --status-success-bg: rgba(34, 197, 94, .12);
  --status-success-bd: rgba(34, 197, 94, .22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, .10), transparent 24%),
    radial-gradient(circle at bottom right, rgba(34, 211, 238, .08), transparent 22%),
    var(--bg);
  color: var(--text);
}

.container {
  width: min(1280px, calc(100% - 28px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: color-mix(in srgb, var(--bg) 76%, transparent);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: .92rem;
  font-weight: 800;
  color: #04111f;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -.02em;
}

.muted {
  color: var(--muted);
  font-size: .92rem;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.app-shell {
  padding: 24px 0 40px;
}

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

.stat-card,
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 18px;
}

.stat-label {
  font-size: .82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.stat-value {
  margin-top: 8px;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -.04em;
}

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: start;
}

.left-column,
.right-column {
  display: grid;
  gap: 16px;
}

.card {
  padding: 18px;
}

.card h2,
.card h3 {
  margin: 0 0 6px;
  font-size: 1.02rem;
  letter-spacing: -.02em;
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

label {
  font-size: .9rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--soft-2);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 13px;
  outline: none;
  font: inherit;
  transition: .18s ease;
}

input:focus,
select:focus {
  border-color: color-mix(in srgb, var(--primary) 70%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}

.field-error {
  min-height: 18px;
  color: var(--danger);
  font-size: .78rem;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row.wrap {
  flex-wrap: wrap;
}

.row-between {
  justify-content: space-between;
}

.actions-row {
  margin-top: 14px;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: .9rem;
  color: var(--muted);
}

.inline-field select {
  min-width: 120px;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
  box-shadow: 0 10px 22px rgba(15, 23, 42, .10);
}

.btn:hover {
  transform: translateY(-1px);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: #04111f;
}

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

.btn-danger {
  background: linear-gradient(135deg, #fda4af, var(--danger));
  color: #450a0a;
}

.helper-text {
  margin-top: 10px;
  font-size: .84rem;
  color: var(--muted);
}

.chart-head {
  margin-bottom: 12px;
}

.chart-wrap {
  position: relative;
  min-height: 320px;
}

.table-wrap {
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-top: 10px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  font-size: .9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--soft);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

tbody tr:hover td {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.symbol-btn {
  background: transparent;
  border: 0;
  color: var(--primary);
  padding: 0;
  font-weight: 800;
  cursor: pointer;
}

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

.mini-btn {
  border: 1px solid var(--border);
  background: var(--soft);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
}

.mini-btn.danger {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.pnl-pos {
  color: var(--success);
  font-weight: 800;
}

.pnl-neg {
  color: var(--danger);
  font-weight: 800;
}

.empty-state {
  margin-top: 12px;
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}

.list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--soft-2);
}

.list .quote-link {
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.status {
  display: none;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--status-info-bd);
  background: var(--status-info-bg);
}

.status.show {
  display: block;
}

.status.info {
  border-color: var(--status-info-bd);
  background: var(--status-info-bg);
}

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

.status.success {
  border-color: var(--status-success-bd);
  background: var(--status-success-bg);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 0 26px;
}

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

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

@media (max-width: 640px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .header-inner,
  .row {
    flex-wrap: wrap;
  }

  .header-actions,
  .actions-row {
    width: 100%;
  }

  .header-actions .btn,
  .actions-row .btn {
    width: 100%;
  }

  .chart-wrap {
    min-height: 260px;
  }
}
