:root {
  --green: #42f58d;
  --cyan: #65e4ff;
  --ink: #03120a;
  --muted: #53645a;
  --line: #d7e5de;
  --panel: #ffffff;
  --soft: #f3fbf7;
  --orange: #ffad42;
  --orange-soft: #ffe0ad;
  --red: #ff6b6b;
  --red-soft: #ffd6d6;
  --shadow: 0 16px 42px rgba(3, 18, 10, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef7f3;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px clamp(14px, 4vw, 34px);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(18px, 4vw, 28px);
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

main {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 28px) 36px;
}

.auth-view {
  min-height: calc(100vh - 88px);
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(460px, 100%);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-panel h2,
.section-head h2 {
  margin: 0;
  font-size: clamp(22px, 5vw, 34px);
  line-height: 1.08;
  letter-spacing: 0;
}

.auth-panel p,
.section-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.stack-form,
.subscriber-form {
  display: grid;
  gap: 13px;
  margin-top: 20px;
}

label {
  display: grid;
  gap: 6px;
  color: #254136;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #b7cbc1;
  border-radius: 6px;
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(66, 245, 141, .22);
}

.primary-button,
.secondary-button,
.icon-button,
.tab {
  min-height: 38px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
}

.primary-button,
.icon-button {
  color: var(--ink);
  border: 1px solid rgba(66, 245, 141, .75);
  background: linear-gradient(90deg, var(--green), var(--cyan));
}

.secondary-button,
.tab {
  color: #0d2d20;
  background: #fff;
  border: 1px solid var(--line);
}

.compact {
  padding: 0 16px;
}

.error-line {
  min-height: 18px;
  margin: 8px 0 0;
  color: #9d1d1d;
  font-size: 13px;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
  overflow-x: auto;
}

.tab {
  padding: 0 16px;
  white-space: nowrap;
}

.tab.active {
  border-color: rgba(66, 245, 141, .75);
  background: linear-gradient(90deg, rgba(66, 245, 141, .22), rgba(101, 228, 255, .22));
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.graph-grid,
.stats-grid,
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.indicator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.market-section {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(3, 18, 10, .07);
}

.market-section header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.market-section h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.market-section .meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.desktop-ribbon {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 9px 12px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.legend {
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 11px;
  text-transform: uppercase;
}

.legend.nominated {
  background: linear-gradient(90deg, rgba(66, 245, 141, .7), rgba(101, 228, 255, .62));
}

.legend.eligible {
  background: var(--orange-soft);
}

.legend.watch-only {
  background: var(--red-soft);
}

.table-viewport {
  max-height: 412px;
  overflow-y: auto;
  overflow-x: auto;
}

.row-table {
  width: 100%;
  border-collapse: collapse;
}

.row-table th,
.row-table td {
  padding: 9px 8px;
  border-bottom: 1px solid #eef3f0;
  font-size: 12px;
  text-align: left;
  vertical-align: top;
}

.row-table th {
  color: #365447;
  background: #fbfdfc;
  font-size: 11px;
  text-transform: uppercase;
}

.row-table tr.nominated td {
  background: linear-gradient(90deg, rgba(66, 245, 141, .42), rgba(101, 228, 255, .28));
}

.row-table tr.eligible td {
  background: var(--orange-soft);
}

.row-table tr.watch-only td {
  background: var(--red-soft);
}

.symbol-cell {
  font-weight: 900;
}

.link-button {
  padding: 0;
  color: #063c25;
  background: transparent;
  border: 0;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.status-pill {
  display: inline-block;
  min-width: 74px;
  padding: 4px 7px;
  border-radius: 999px;
  text-align: center;
  font-size: 11px;
  font-weight: 900;
}

.nominated .status-pill {
  background: var(--green);
}

.eligible .status-pill {
  background: var(--orange);
}

.watch-only .status-pill {
  background: var(--red);
  color: #3b0505;
}

.pane-action {
  min-width: 92px;
  padding: 0 10px;
  white-space: nowrap;
}

.mini-button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 11px;
}

.compact-row {
  justify-content: flex-end;
}

.focus-card,
.graph-card,
.stats-card,
.portfolio-card,
.portfolio-form {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(3, 18, 10, .07);
}

.portfolio-layout {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, 1fr) minmax(300px, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.portfolio-form {
  display: grid;
  gap: 10px;
}

.portfolio-form h3 {
  margin: 0;
  font-size: 18px;
}

.portfolio-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.portfolio-card h3 {
  margin: 0;
  font-size: 18px;
}

.portfolio-card p,
.portfolio-empty {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.portfolio-table-wrap {
  max-height: 420px;
  overflow: auto;
  border: 1px solid #e2eee8;
}

.portfolio-table tr.sell-needed td {
  background: var(--red-soft);
  animation: pulse-red 1s infinite;
}

.portfolio-table tr.sell-nominated td {
  background: var(--orange-soft);
  animation: pulse-orange 1.8s infinite;
}

.portfolio-table tr.sold td {
  background: #ecefed;
  color: #59645f;
}

@keyframes pulse-red {
  0%, 100% { background: #ffd6d6; }
  50% { background: #ff9f9f; }
}

@keyframes pulse-orange {
  0%, 100% { background: #ffe0ad; }
  50% { background: #ffc66f; }
}

.focus-table {
  max-height: 680px;
  overflow: auto;
  border: 1px solid #e2eee8;
}

.graph-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.graph-card h3,
.stats-card h3 {
  margin: 0;
  font-size: 18px;
}

.bar-list,
.rank-list {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
}

.bars {
  display: grid;
  gap: 3px;
}

.score-bar,
.momentum-bar {
  display: block;
  height: 9px;
  min-width: 4px;
  border-radius: 999px;
}

.score-bar {
  background: linear-gradient(90deg, var(--green), var(--cyan));
}

.momentum-bar {
  background: var(--orange);
}

.momentum-bar.negative {
  background: var(--red);
}

.graph-symbol {
  text-align: left;
}

.rank-row {
  display: grid;
  grid-template-columns: 28px 70px minmax(0, 1fr) 72px;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 7px 8px;
  color: var(--ink);
  background: #fbfdfc;
  border: 1px solid #e2eee8;
  text-align: left;
}

.rank-row span,
.rank-row b {
  font-weight: 900;
}

.rank-row em {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
}

.subscriber-form,
.subscriber-list {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(3, 18, 10, .07);
}

.subscriber-form h3,
.subscriber-list h3 {
  margin: 0;
  font-size: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.button-row,
.list-title {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.button-row button,
.list-title button {
  padding: 0 14px;
}

.subscriber-rows {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  max-height: 650px;
  overflow: auto;
}

.subscriber-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fbfdfc;
}

.subscriber-card.expired {
  border-color: var(--red);
  background: var(--red-soft);
}

.subscriber-card.disabled {
  opacity: .66;
}

.subscriber-card h4 {
  margin: 0;
  font-size: 16px;
}

.subscriber-card p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-actions button {
  padding: 0 12px;
}

.symbol-search {
  display: grid;
  grid-template-columns: minmax(120px, 180px) auto;
  gap: 8px;
  align-items: center;
}

.indicator-card,
.detail-card {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(3, 18, 10, .07);
}

.indicator-card.positive-watch,
.indicator-card.risk-easing,
.indicator-card.rate-relief,
.indicator-card.improving {
  border-color: rgba(66, 245, 141, .75);
}

.indicator-card.negative-watch,
.indicator-card.risk-rising,
.indicator-card.rate-pressure,
.indicator-card.weakening {
  border-color: var(--red);
}

.indicator-title,
.detail-title {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.indicator-title h3,
.detail-title h3,
.detail-card h4 {
  margin: 0;
}

.indicator-title p,
.detail-title p,
.indicator-card p,
.detail-card p,
.detail-card li {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

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

.metric-grid div {
  min-height: 58px;
  padding: 9px;
  background: #f7fbf9;
  border: 1px solid #e2eee8;
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 15px;
}

.detail-panel {
  min-height: 240px;
}

.detail-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.detail-columns section {
  padding: 12px;
  background: #fbfdfc;
  border: 1px solid #e2eee8;
}

.detail-columns ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.headline-list a {
  color: #063c25;
  font-weight: 700;
}

@media (max-width: 900px) {
  .section-grid,
  .graph-grid,
  .stats-grid,
  .portfolio-grid,
  .indicator-grid,
  .portfolio-layout,
  .admin-layout,
  .detail-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-head,
  .button-row,
  .list-title {
    align-items: stretch;
    flex-direction: column;
  }

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

  .symbol-search,
  .metric-grid,
  .metric-grid.wide {
    grid-template-columns: 1fr;
  }

  .row-table th:nth-child(4),
  .row-table td:nth-child(4),
  .row-table th:nth-child(5),
  .row-table td:nth-child(5) {
    display: none;
  }
}
