:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #748096;
  --line: #e8ebf2;
  --blue: #3f7cff;
  --purple: #7657ff;
  --orange: #ff9f43;
  --green: #21a67a;
  --red: #e25454;
  --shadow: 0 18px 45px rgba(31, 43, 72, 0.1);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 15% 10%, rgba(63, 124, 255, 0.12), transparent 28%), var(--bg);
}
button, input, select { font: inherit; }
button { cursor: pointer; border: 0; }
.hidden { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px;
}
.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  margin-bottom: 20px;
}
.brand-mark.small {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  margin: 0;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.8rem, 5vw, 2.8rem); }
h2 { margin-bottom: 0; font-size: 1rem; }
.muted, .fine-print, .security-note { color: var(--muted); }
.fine-print, .security-note { font-size: 0.82rem; line-height: 1.45; }
.login-form { display: grid; gap: 12px; margin-top: 24px; }
label { color: var(--muted); font-size: 0.86rem; font-weight: 700; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
  color: var(--ink);
  padding: 12px;
  outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(63, 124, 255, 0.12); }
.login-form button, .secondary-button {
  min-height: 42px;
  color: white;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--blue), var(--purple));
  font-weight: 800;
}
.login-form .link-button {
  min-height: 0;
  padding: 0;
  color: var(--blue);
  background: transparent;
  box-shadow: none;
  font-size: 0.86rem;
  text-align: left;
}
.login-form .link-button:hover { text-decoration: underline; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
}
.sidebar-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 34px; }
.sidebar-brand span, .panel-head span, .metric-card span, .metric-card small { color: var(--muted); font-size: 0.82rem; }
.nav-list { display: grid; gap: 8px; }
.nav-item, .ghost-button {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.nav-item.active, .nav-item:hover { color: var(--ink); background: #eef3ff; }
.ghost-button { position: absolute; left: 18px; bottom: 24px; width: calc(100% - 36px); color: var(--red); }

.content-shell { padding: 28px; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h1 { margin: 0; }
.top-summary {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: 0 10px 24px rgba(31, 43, 72, 0.06);
}
.top-summary span { color: var(--muted); }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 18px; min-width: 0; }
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}
.pill.buy { background: rgba(33, 166, 122, 0.12); color: var(--green); }
.pill.accumulate { background: rgba(63, 124, 255, 0.12); color: var(--blue); }
.pill.hold { background: rgba(255, 159, 67, 0.14); color: #b66b08; }
.pill.avoid { background: rgba(226, 84, 84, 0.12); color: var(--red); }
.pill.neutral { background: rgba(116, 128, 150, 0.14); color: var(--muted); }

.ticker-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(320px, 1.4fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 16px;
}
.ticker-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.ticker-form label { grid-column: 1 / -1; }

.table-panel { margin-bottom: 16px; }
.table-actions { align-items: flex-start; }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; }
.secondary-button, .danger-button {
  padding: 10px 13px;
  min-height: 38px;
}
.danger-button { color: var(--red); background: rgba(226, 84, 84, 0.11); border-radius: var(--radius); font-weight: 800; }
.icon-action {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(31, 43, 72, 0.07);
}
.icon-action.primary { color: white; background: linear-gradient(135deg, var(--blue), var(--purple)); }
.icon-action.neutral { color: var(--ink); background: #eef3ff; }
.icon-action.active { color: white; background: var(--ink); }
.icon-action.warning { color: #9a5b06; background: rgba(255, 159, 67, 0.16); }
.icon-action.danger { color: var(--red); background: rgba(226, 84, 84, 0.12); }
.icon-action:disabled { cursor: not-allowed; opacity: 0.38; box-shadow: none; }
.column-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
}
.column-panel-head {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 2px;
}
.column-panel-head span { color: var(--muted); font-size: 0.82rem; }
.column-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
}
.column-toggle label { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); }
.column-toggle input { width: 16px; min-width: 16px; height: 16px; padding: 0; accent-color: var(--blue); }
.column-move { display: inline-flex; gap: 4px; }
.column-move button {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--blue);
  background: #eef3ff;
  font-weight: 900;
}
.column-move button:disabled { opacity: 0.32; cursor: not-allowed; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 1480px; }
th, td { border-bottom: 1px solid var(--line); padding: 9px; text-align: left; font-size: 0.82rem; white-space: nowrap; }
th { color: var(--muted); background: #f8faff; position: sticky; top: 0; z-index: 1; }
.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  color: inherit;
  background: transparent;
  font-weight: 800;
}
.sort-button span { min-width: 10px; color: var(--blue); }
.table-link {
  color: var(--blue);
  font-weight: 900;
  text-decoration: none;
}
.table-link:hover { text-decoration: underline; }
td input { min-width: 112px; padding: 8px; font-size: 0.82rem; }
input.row-check {
  width: 18px;
  min-width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--blue);
}
td .readonly { font-weight: 800; }
.sector-row td {
  color: var(--muted);
  font-weight: 900;
  background: #f0f4fb;
  text-transform: uppercase;
}
.company-logo, .logo-fallback {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.company-logo {
  object-fit: contain;
  padding: 4px;
  border: 1px solid var(--line);
  background: white;
}
.logo-fallback {
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--blue), var(--purple));
}
.row-actions { display: flex; gap: 4px; }
.delete-row, .icon-button {
  min-width: 32px;
  min-height: 32px;
  border-radius: var(--radius);
  background: transparent;
  font-weight: 900;
}
.delete-row { color: var(--red); }
.icon-button { color: var(--blue); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    display: grid;
    gap: 14px;
    padding: 16px;
  }
  .sidebar-brand { margin-bottom: 0; }
  .nav-list { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .nav-item { min-width: max-content; }
  .ghost-button { position: static; width: auto; }
  .ticker-panel { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .content-shell { padding: 16px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-summary { width: 100%; justify-content: space-between; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .login-card { padding: 24px; }
  .ticker-form { grid-template-columns: 1fr; }
}
