:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --ink: #15201d;
  --muted: #63706b;
  --line: #d8dfda;
  --accent: #087b83;
  --accent-strong: #065a60;
  --good: #187044;
  --bad: #ad2f2f;
  --soft: #edf4f2;
  --shadow: 0 14px 38px rgba(22, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
}

button {
  border: 0;
  background: var(--accent);
  color: white;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-panel h1,
.brand-block h1,
.topbar h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.form-error {
  min-height: 22px;
  color: var(--bad);
  margin: 0;
}

.login-2fa {
  display: grid;
  gap: 8px;
}

.login-2fa p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr) auto;
  gap: 22px;
  min-height: 100vh;
  padding: 22px;
  background: #263936;
  color: #fff;
}

.sidebar label,
.sidebar .eyebrow {
  color: #b9c8c5;
}

.brand-block h1 {
  font-size: 1.65rem;
}

.eyebrow {
  margin: 0 0 5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.search-block {
  position: relative;
  display: grid;
  gap: 9px;
}

.search-results {
  display: grid;
  gap: 7px;
}

.search-result,
.watch-item {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 54px;
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  text-align: left;
}

.search-result:hover,
.watch-item:hover,
.watch-item.active {
  background: rgba(255, 255, 255, 0.16);
}

.search-result strong,
.watch-item strong {
  font-size: 0.95rem;
}

.search-result span,
.watch-item span {
  color: #c8d6d3;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 800;
}

.icon-button {
  min-width: 34px;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.13);
}

.watchlist {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: calc(100vh - 340px);
  overflow: auto;
  padding-right: 2px;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  min-height: 96px;
  border-bottom: 1px solid var(--line);
}

.quote-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
}

.quote-strip div {
  min-width: 120px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.quote-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
}

.quote-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
}

.positive {
  color: var(--good);
}

.negative {
  color: var(--bad);
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 18px 0 14px;
}

.tab {
  flex: 0 0 auto;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.tab-panel {
  display: none;
  min-height: calc(100vh - 196px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

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

.chart-toolbar,
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.chart-toolbar h3,
.panel-header h3 {
  margin: 0;
}

.chart-toolbar p,
.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.authority-form {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(90px, 0.6fr) minmax(100px, 0.6fr) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.security-note {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
}

.security-note p {
  margin: 0;
  color: var(--muted);
}

.checkbox-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.status-line {
  min-height: 24px;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 700;
}

.alias-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.alias-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 12px;
}

.alias-group h4 {
  margin: 0 0 10px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.alias-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: #fff;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.alias-chip.context {
  background: #fff8ea;
  border-color: #e5c47d;
}

.alias-chip.direct {
  background: var(--soft);
  border-color: #bcd6d2;
}

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

.chart-canvas {
  width: 100%;
  aspect-ratio: 2.6 / 1;
  min-height: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(#ffffff, #f8fbfa);
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.segmented button {
  min-height: 32px;
  color: var(--muted);
  background: transparent;
}

.segmented button.active {
  color: #fff;
  background: var(--accent);
}

.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.metric {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.table-zone,
.news-list,
.json-output {
  max-height: calc(100vh - 280px);
  overflow: auto;
}

.json-output {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
  white-space: pre-wrap;
}

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

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #eef5f3;
}

.news-item {
  display: grid;
  gap: 5px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.news-item a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.news-item p {
  margin: 0;
  color: var(--muted);
}

.event-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.event-preview {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.event-preview div,
.event-detail {
  display: grid;
  gap: 5px;
}

.event-preview strong,
.event-detail strong {
  font-size: 0.86rem;
}

.event-preview a,
.event-detail a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.event-preview span,
.event-detail span {
  color: var(--muted);
  font-size: 0.78rem;
}

.event-dot-button {
  width: 18px;
  min-width: 18px;
  min-height: 18px;
  border-radius: 50%;
  padding: 0;
  margin-top: 3px;
  background: #a85127;
}

.event-detail {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.event-detail a {
  display: grid;
  gap: 2px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    grid-template-rows: auto;
  }

  .watchlist {
    max-height: 220px;
  }

  .topbar,
  .chart-toolbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .quote-strip {
    grid-template-columns: 1fr;
  }
}
