:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --up: #00a63e;
  --down: #ef1d1d;
  --flat: #6b7280;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 1700px;
  margin: 0 auto;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.subtitle {
  color: var(--muted);
  margin: 0;
}

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

.toolbar-label {
  font-size: 13px;
  color: #334155;
}

.auth-user {
  font-size: 13px;
  color: #1f2937;
  font-weight: 600;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 6px 10px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

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

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

.status-pill {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  background: #e0e7ff;
  color: #1e3a8a;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: visible;
  box-shadow: 0 8px 28px rgba(17, 24, 39, 0.06);
}

.table-wrap {
  max-height: calc(100vh - 220px);
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1600px;
  border-collapse: separate;
  border-spacing: 0 3px;
  background: #f4f7fb;
}

th,
td {
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  padding: 5px 6px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  background: #ffffff;
}

tbody td:first-child {
  border-left: 1px solid #e2e8f0;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

tbody td:last-child {
  border-right: 1px solid #e2e8f0;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

tbody tr td {
  box-shadow: 0 1px 0 rgba(148, 163, 184, 0.18);
}

thead th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  z-index: 40;
  color: #374151;
  font-size: 13px;
  box-shadow: 0 2px 0 rgba(148, 163, 184, 0.22);
}

.th-sort {
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

.th-sort:hover {
  color: var(--primary);
}

tr:hover td {
  background: #eef6ff;
  border-top-color: #bfdbfe;
  border-bottom-color: #bfdbfe;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 6px;
  background: #fff;
  min-height: 28px;
}

.ticker-input {
  width: clamp(7ch, calc(var(--ticker-ch, 6) * 1ch), 12ch);
  min-width: 7ch;
  max-width: 100%;
}

#table-select,
#analyst-name-input {
  border: 1px solid var(--border);
  border-radius: 7px;
  min-height: 30px;
  padding: 4px 8px;
  background: #fff;
}

#analyst-name-input {
  min-width: 160px;
}

input:focus {
  outline: 2px solid #bfdbfe;
  border-color: #93c5fd;
}

input[readonly] {
  background: #f3f4f6;
  color: #6b7280;
  cursor: not-allowed;
}

.readonly-cell {
  background: #f9fafb;
  font-variant-numeric: tabular-nums;
  text-align: center;
  font-weight: 600;
}

.readonly-cell span {
  display: inline-block;
  text-align: center;
}

.upside-up {
  color: var(--up);
  font-weight: 700;
  background: rgba(0, 166, 62, 0.22);
  box-shadow: inset 0 0 0 1px rgba(0, 166, 62, 0.32);
}

.upside-up-strong {
  color: #064e3b;
  font-weight: 800;
  background: rgba(34, 197, 94, 0.45);
  box-shadow: inset 0 0 0 1px rgba(21, 128, 61, 0.5);
}

.upside-down {
  color: var(--down);
  font-weight: 700;
  background: rgba(239, 29, 29, 0.22);
  box-shadow: inset 0 0 0 1px rgba(239, 29, 29, 0.32);
}

.upside-flat {
  color: var(--flat);
  font-weight: 600;
  background: rgba(107, 114, 128, 0.14);
}

.btn-danger {
  border: none;
  background: var(--danger);
  color: #fff;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.status-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
}

.hidden {
  display: none !important;
}

.comparison-inline-row td {
  background: #ffffff;
}

.comparison-inline-row input[disabled] {
  opacity: 1;
  color: inherit;
  -webkit-text-fill-color: currentColor;
  background: #ffffff;
}

.ticker-compare-highlight td {
  background: #fde68a;
  border-top-color: #f59e0b;
  border-bottom-color: #f59e0b;
  box-shadow: inset 0 0 0 1px #f59e0b;
}

.comparison-source {
  font-weight: 700;
  color: #92400e;
}
