:root {
  --ink: #111116;
  --muted: #696974;
  --line: rgba(17, 17, 22, 0.09);
  --surface: #ffffff;
  --page: #f4f4f6;
  --accent: #7861ff;
  --danger: #b91c1c;
  --ok: #057a55;
  --warn: #a16207;
  --soft-shadow: 0 6px 18px rgba(16, 16, 20, 0.035);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

a {
  color: inherit;
}

.crm-body {
  background: var(--page);
}

.crm-layout {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
}

.crm-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 286px;
  min-width: 286px;
  height: 100vh;
  padding: 0.9rem;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 24px rgba(16, 16, 20, 0.04);
}

.brand-account-menu summary {
  list-style: none;
}

.brand-account-menu summary::-webkit-details-marker {
  display: none;
}

.brand-box,
.page-header,
.workspace-panel,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--soft-shadow);
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 74px;
  padding: 0.66rem;
  background: #fff;
  cursor: pointer;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 9px;
  background: #111116;
}

.brand-mark img {
  width: 32px;
  height: 30px;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.brand-copy strong {
  font-size: 1rem;
  line-height: 1.1;
}

.brand-subtitle,
.page-description,
.workspace-panel p,
td span,
.empty-state {
  color: var(--muted);
}

.brand-subtitle {
  font-size: 0.76rem;
  font-weight: 700;
}

.account-menu-panel {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.5rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.account-menu-identity,
.account-menu-action {
  display: grid;
  gap: 0.12rem;
  width: 100%;
  padding: 0.58rem 0.68rem;
  border-radius: 8px;
  background: #f7f7f9;
}

.account-menu-identity span {
  color: var(--muted);
  font-size: 0.72rem;
}

.account-menu-action,
button,
.button-link {
  min-height: 2.35rem;
  padding: 0.56rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  background: #f5f5f7;
  cursor: pointer;
}

button:hover,
.button-link:hover,
.nav-link:hover {
  background: rgba(120, 97, 255, 0.12);
}

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

.button-link {
  display: inline-grid;
  align-items: center;
}

.button-link.muted {
  color: var(--muted);
  background: #fff;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  width: 100%;
}

.language-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.language-switcher button {
  min-height: 2rem;
  padding: 0.35rem;
  border-radius: 8px;
  font-size: 0.78rem;
}

.language-switcher button.is-active {
  color: #fff;
  background: #000;
}

.login-language-switcher {
  margin-bottom: 1rem;
}

.nav-link {
  display: grid;
  gap: 0.15rem;
  min-height: 48px;
  padding: 0.56rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.72);
  position: relative;
}

.nav-link strong {
  font-size: 0.92rem;
}

.nav-link span {
  color: var(--muted);
  font-size: 0.72rem;
}

.nav-link.is-active {
  color: #fff;
  background: #000;
  border-color: #000;
}

.nav-link.is-active span {
  color: #fff;
}

.nav-link.is-loading {
  border-color: var(--ink);
}

.nav-link.is-loading::after {
  background: currentColor;
  border-radius: 999px;
  content: "";
  height: 8px;
  position: absolute;
  right: 0.65rem;
  top: 0.65rem;
  width: 8px;
}

.crm-main {
  display: grid;
  align-content: start;
  gap: 0.9rem;
  width: 100%;
  max-width: 1560px;
  min-width: 0;
  padding: 1.05rem clamp(1rem, 2vw, 1.7rem) 2rem;
}

.page-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.1rem;
}

.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: 2rem;
  line-height: 1.08;
}

.page-header p,
.workspace-panel p {
  margin: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.stat-card {
  display: grid;
  gap: 0.25rem;
  min-height: 96px;
  padding: 1rem;
}

.stat-card span,
.finder-metrics span,
label span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.25;
  text-transform: uppercase;
}

.stat-card strong {
  font-size: 1.9rem;
}

.stat-card small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-card-link {
  color: inherit;
  text-decoration: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.stat-card-link:hover {
  border-color: rgba(17, 17, 22, 0.24);
  box-shadow: 0 16px 34px rgba(17, 17, 22, 0.08);
  transform: translateY(-1px);
}

.exchange-hours-card strong {
  color: var(--ok);
}

.exchange-hours-panel {
  scroll-margin-top: 1rem;
}

.exchange-hours-checked {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.exchange-hours-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 0.8rem;
}

.exchange-card {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.exchange-card-head {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  justify-content: space-between;
}

.exchange-card-head strong,
.exchange-card-head span {
  display: block;
}

.exchange-card-head strong {
  font-size: 1rem;
}

.exchange-card-head div > span {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.exchange-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.65rem;
  padding: 0.2rem 0.52rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.exchange-badge-open {
  color: var(--ok);
  background: rgba(5, 122, 85, 0.1);
}

.exchange-badge-closed {
  color: var(--danger);
  background: rgba(185, 28, 28, 0.1);
}

.exchange-meta {
  grid-template-columns: 1fr;
  gap: 0.42rem;
  margin: 0;
}

.exchange-meta div {
  display: grid;
  gap: 0.1rem;
}

.sensor-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 0.8rem;
}

.sensor {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  min-height: 64px;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.sensor div {
  min-width: 0;
}

.sensor strong,
.sensor span {
  display: block;
}

.sensor strong {
  font-size: 0.88rem;
}

.sensor div span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.sensor small {
  display: block;
  max-width: 100%;
  margin-top: 0.12rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: normal;
}

.sensor-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  background: var(--muted);
}

.sensor-ok .sensor-dot {
  background: var(--ok);
}

.sensor-disabled .sensor-dot {
  background: #a1a1aa;
}

.sensor-stub .sensor-dot {
  background: #d97706;
}

.sensor-blocked .sensor-dot {
  background: #d97706;
}

.sensor-error .sensor-dot {
  background: var(--danger);
}

.workspace-panel {
  padding: 1rem;
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.panel-head h2 {
  margin: 0 0 0.25rem;
  font-size: 1.12rem;
}

.finder-metrics,
.period-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.55rem;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.analytics-card {
  display: grid;
  gap: 0.22rem;
  min-height: 86px;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.analytics-card span,
.analytics-row span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.analytics-card strong {
  font-size: 1.65rem;
}

.analytics-card small {
  color: var(--muted);
  font-weight: 800;
}

.analytics-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.analytics-columns-secondary {
  margin-top: 0.65rem;
}

.analytics-columns article {
  min-height: 150px;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.analytics-columns h3 {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
}

.analytics-row {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.42rem 0;
  border-bottom: 1px solid var(--line);
}

.analytics-row:last-child {
  border-bottom: 0;
}

.analytics-row strong {
  max-width: 58%;
  font-size: 0.9rem;
  line-height: 1.25;
  text-align: right;
  overflow-wrap: anywhere;
}

.analytics-row span {
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.analytics-card small {
  line-height: 1.25;
}

.analytics-bar-row {
  display: grid;
  gap: 0.32rem;
  padding: 0.52rem 0;
  border-bottom: 1px solid var(--line);
}

.analytics-bar-row:last-child {
  border-bottom: 0;
}

.analytics-bar-head {
  display: flex;
  justify-content: space-between;
  gap: 0.65rem;
  align-items: center;
}

.analytics-bar-head span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.25;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.analytics-bar-head strong {
  flex: 0 0 auto;
  font-size: 0.88rem;
}

.analytics-bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.analytics-bar-track i {
  display: block;
  height: 100%;
  min-width: 6px;
  border-radius: inherit;
  background: #2563eb;
}

.analytics-bar-track .analytics-bar-positive {
  background: #16a34a;
}

.analytics-bar-track .analytics-bar-risk {
  background: #dc2626;
}

.analytics-bar-row small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.25;
}

.finder-metrics div,
.period-grid article {
  min-height: 74px;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.finder-metrics strong,
.period-grid strong {
  display: block;
  margin-top: 0.3rem;
  font-size: 1.35rem;
}

.period-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.period-grid h3 {
  margin: 0;
  font-size: 0.92rem;
}

.period-grid span {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.table-wrap .crm-table {
  border: 0;
  border-radius: 0;
}

.recommendations-table {
  min-width: 980px;
}

.recommendations-table .col-ticker {
  width: 12%;
}

.recommendations-table .col-market {
  width: 12%;
}

.recommendations-table .col-author {
  width: 12%;
}

.recommendations-table .col-direction {
  width: 12%;
}

.recommendations-table .col-status,
.recommendations-table .col-result {
  width: 15%;
}

.recommendations-table .col-rr {
  width: 7%;
}

.recommendations-table .col-published {
  width: 15%;
}

.recommendations-table .col-review-reason {
  width: 18%;
}

.crm-table th,
.crm-table td {
  padding: 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.crm-table th {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  background: #f7f7f9;
}

.crm-table td {
  font-size: 0.86rem;
  font-weight: 700;
}

.cell-value {
  min-width: 0;
  max-width: 100%;
}

.nowrap {
  white-space: nowrap;
}

.date-value {
  display: inline-block;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  overflow-wrap: normal;
  word-break: normal;
}

.crm-table code {
  display: inline-block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.table-link {
  color: #111;
  font-weight: 900;
}

.badge {
  display: inline-flex;
  min-height: 1.55rem;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 0.18rem 0.46rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
  background: #f7f7f9;
}

.badge-active,
.badge-win,
.badge-reviewed,
.badge-published {
  color: var(--ok);
  background: rgba(5, 122, 85, 0.1);
}

.badge-loss,
.badge-error,
.badge-cancelled {
  color: var(--danger);
  background: rgba(185, 28, 28, 0.1);
}

.badge-needs_review,
.badge-carry,
.badge-draft,
.badge-partial {
  color: var(--warn);
  background: rgba(161, 98, 7, 0.1);
}

.result-cell {
  display: inline-grid;
  gap: 0.28rem;
  justify-items: start;
  max-width: 100%;
}

.signal-status-cell {
  display: inline-grid;
  gap: 0.28rem;
  justify-items: start;
  max-width: 100%;
}

.status-action-link {
  color: var(--danger);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.15;
  text-decoration: none;
}

.status-action-link:hover {
  text-decoration: underline;
}

.result-schedule {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.15;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
  align-items: end;
}

.recommendations-filter-panel {
  padding: 0.72rem;
}

.recommendations-filter-bar {
  grid-template-columns: repeat(3, minmax(120px, 1fr)) auto auto;
  gap: 0.5rem;
}

.recommendations-filter-bar label {
  gap: 0.22rem;
}

.recommendations-filter-bar label span {
  font-size: 0.72rem;
  line-height: 1;
}

.recommendations-filter-bar select,
.recommendations-filter-bar button,
.recommendations-filter-bar .button-link {
  min-height: 2.25rem;
  border-radius: 8px;
  font-size: 0.86rem;
}

.recommendations-filter-bar select {
  padding: 0.38rem 0.55rem;
}

.recommendations-filter-bar button,
.recommendations-filter-bar .button-link {
  min-width: 5.9rem;
  padding: 0.38rem 0.72rem;
}

.recommendations-filter-bar .button-link {
  justify-content: center;
  text-align: center;
}

.form-stack,
.settings-form {
  display: grid;
  gap: 0.75rem;
}

.settings-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 0.28rem;
}

input,
textarea,
select {
  width: 100%;
  min-height: 2.55rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(320px, 0.72fr);
  gap: 1.35rem;
  align-items: start;
}

.detail-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
}

.detail-form button {
  justify-self: start;
}

.delete-signal-form {
  grid-column: 1;
  align-self: start;
}

.danger-button {
  color: #fff;
  border-color: rgba(185, 28, 28, 0.25);
  background: var(--danger);
}

.danger-button:hover {
  background: #991b1b;
}

.source-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-width: 0;
  padding: 0.15rem 0 0 0.9rem;
  border-left: 1px solid var(--line);
}

.compact-source-panel {
  display: grid;
  gap: 0.66rem;
  align-content: start;
}

.source-panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
}

.source-panel h2 {
  margin: 0 0 0.18rem;
  font-size: 1rem;
}

.source-panel-head span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.source-panel-head strong {
  max-width: 9rem;
  overflow: hidden;
  padding: 0.24rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.74rem;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #f7f7f9;
}

dl {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 0.35rem 0.7rem;
  margin: 0 0 1rem;
}

.compact-meta-list {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding-bottom: 0.62rem;
  border-bottom: 1px solid var(--line);
}

.compact-meta-list div {
  display: grid;
  gap: 0.14rem;
  min-width: 0;
}

dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.15;
  text-transform: uppercase;
}

dd {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #2f2f37;
  font-size: 0.84rem;
  line-height: 1.45;
  background: #f7f7f9;
}

.source-message-text {
  max-height: min(460px, calc(100vh - 22rem));
  padding: 0.72rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  color: #1f2027;
  font-size: 0.78rem;
  line-height: 1.38;
  background: #fff;
}

.source-message-secondary {
  max-height: 150px;
  margin-top: 0.55rem;
  background: #f7f7f9;
}

.media-evidence-type {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.source-extra {
  display: grid;
  gap: 0.55rem;
}

.source-extra summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.report-list {
  display: grid;
  gap: 0.8rem;
}

.report-actions-panel {
  padding: 1rem;
}

.report-action-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.report-action-column {
  display: grid;
  gap: 0.7rem;
  min-width: 0;
}

.report-action-group-title {
  display: flex;
  align-items: center;
  min-height: 1.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.report-widget-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  align-items: start;
  min-width: 0;
}

.report-action-widget {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
  min-width: 0;
  min-height: 7.25rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(17, 17, 22, 0.03);
}

.report-action-widget-wide {
  grid-column: 1 / -1;
  grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
  align-items: end;
  min-height: auto;
}

.report-action-widget-cta {
  align-content: center;
  min-height: 4.25rem;
}

.report-action-widget-cta.report-action-widget-wide {
  grid-template-columns: minmax(18rem, 24rem);
  justify-content: start;
}

.report-action-widget-cta.report-action-widget-wide button {
  min-width: 18rem;
}

.report-action-widget label {
  display: grid;
  gap: 0.28rem;
  min-width: 0;
}

.report-action-widget label span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.report-action-widget button {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.46rem 0.72rem;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.18;
  white-space: normal;
}

.compact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.compact-actions form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.compact-actions input {
  width: auto;
  min-width: 142px;
  min-height: 2.05rem;
  padding: 0.34rem 0.5rem;
  border-radius: 8px;
  font-size: 0.78rem;
}

.report-action-widget input {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.46rem 0.62rem;
  border-radius: 8px;
  font-size: 0.86rem;
}

.report-action-widget input[type="date"],
.report-action-widget input[type="month"] {
  min-width: 11.5rem;
}

.button-small {
  min-height: 2.05rem;
  padding: 0.34rem 0.58rem;
  border-radius: 8px;
  font-size: 0.76rem;
  line-height: 1.15;
}

.report-card {
  min-width: 0;
  padding: 0.66rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.report-head {
  display: flex;
  justify-content: space-between;
  gap: 0.55rem;
  align-items: start;
  margin-bottom: 0.35rem;
}

.report-head div {
  display: grid;
  gap: 0.14rem;
  min-width: 0;
}

.report-head strong {
  font-size: 0.95rem;
  line-height: 1.05;
}

.report-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  justify-content: flex-end;
}

.report-head small,
.report-dialog-head span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.published-report-list {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 0.65rem;
}

.published-report-card {
  display: grid;
  gap: 0.5rem;
  align-content: start;
}

.report-preview {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
}

.report-open-button {
  justify-self: start;
}

.report-card-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.35rem;
  align-items: center;
}

.report-card-actions form,
.report-inline-form {
  margin: 0;
}

.report-card-actions .button-small {
  width: 100%;
  white-space: normal;
}

.report-dialog {
  width: min(760px, calc(100vw - 2rem));
  max-height: min(760px, calc(100vh - 2rem));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 24px 64px rgba(16, 16, 20, 0.18);
}

.report-dialog::backdrop {
  background: rgba(17, 17, 22, 0.34);
}

.report-dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: start;
  padding: 0.9rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.report-dialog-head div {
  display: grid;
  gap: 0.18rem;
}

.report-dialog pre {
  max-height: calc(100vh - 9rem);
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: #fff;
}

.notice {
  display: inline-block;
  margin: 0 0 0.8rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  background: #f7f7f9;
}

.notice-error {
  color: var(--danger);
  background: rgba(185, 28, 28, 0.08);
}

.empty-state {
  margin: 0;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 800;
  background: #fff;
}

.rai-signature {
  position: fixed;
  left: 1rem;
  bottom: 0.75rem;
  z-index: 20;
  padding: 0.32rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
}

.rai-assistant {
  position: fixed;
  right: 1rem;
  bottom: 3.1rem;
  z-index: 40;
  width: max-content;
  max-width: calc(100vw - 2rem);
  font-size: 0.86rem;
}

.rai-assistant-launcher {
  box-sizing: border-box;
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  min-width: 58px;
  min-height: 58px;
  max-width: 58px;
  max-height: 58px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(17, 17, 22, 0.16);
  border-radius: 16px;
  color: #fff;
  line-height: 1;
  background: #111116;
  box-shadow: 0 16px 34px rgba(17, 17, 22, 0.22);
  appearance: none;
}

.rai-assistant-launcher::before {
  position: absolute;
  inset: -10px;
  border-radius: 22px;
  background: rgba(120, 97, 255, 0.18);
  animation: assistant-launcher-glow 4s ease-in-out infinite;
  content: "";
}

.rai-assistant-launcher img {
  position: relative;
  display: block;
  width: 34px;
  height: 32px;
  max-width: 34px;
  max-height: 32px;
  object-fit: contain;
}

.rai-assistant-panel {
  position: absolute;
  right: 0;
  bottom: 4.4rem;
  display: grid;
  grid-template-rows: auto minmax(170px, 1fr) auto auto;
  gap: 0.55rem;
  width: min(380px, calc(100vw - 2rem));
  max-height: min(560px, calc(100vh - 5.5rem));
  padding: 0.7rem;
  border: 1px solid rgba(17, 17, 22, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.985);
  box-shadow: 0 26px 70px rgba(16, 16, 20, 0.2);
  backdrop-filter: blur(14px);
}

.rai-assistant-panel[hidden] {
  display: none;
}

.rai-assistant-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.rai-assistant-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #111116;
}

.rai-assistant-mark img {
  width: 23px;
  height: 22px;
  object-fit: contain;
}

.rai-assistant-head strong,
.rai-assistant-head span {
  display: block;
}

.rai-assistant-head strong {
  font-size: 0.88rem;
  line-height: 1.1;
}

.rai-assistant-head span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  line-height: 1.18;
}

.rai-assistant-close {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
  font-size: 1rem;
}

.rai-assistant-messages {
  display: grid;
  align-content: start;
  gap: 0.42rem;
  min-height: 170px;
  max-height: 310px;
  padding: 0.55rem;
  overflow: auto;
  border: 1px solid rgba(17, 17, 22, 0.08);
  border-radius: 14px;
  background: linear-gradient(180deg, #f8f8fa 0%, #f2f2f5 100%);
}

.rai-assistant-message {
  max-width: 94%;
  max-height: 11.5rem;
  padding: 0.58rem 0.66rem;
  border: 1px solid rgba(17, 17, 22, 0.08);
  border-radius: 12px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
  line-height: 1.34;
  background: #fff;
  box-shadow: 0 8px 22px rgba(17, 17, 22, 0.04);
}

.rai-assistant-message.is-user {
  justify-self: end;
  color: #fff;
  background: #111116;
  border-color: #111116;
}

.rai-assistant-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  margin-top: 0.64rem;
}

.rai-assistant-link {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.36rem 0.66rem;
  border: 1px solid rgba(17, 17, 22, 0.12);
  border-radius: 10px;
  color: #111116;
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1.1;
  text-decoration: none;
  background: linear-gradient(180deg, #fff 0%, #f1f1f4 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 8px 18px rgba(17, 17, 22, 0.06);
}

.rai-assistant-link:hover {
  border-color: rgba(17, 17, 22, 0.24);
  background: #111116;
  color: #fff;
}

.rai-assistant-form {
  display: grid;
  grid-template-columns: auto auto minmax(8rem, 1fr);
  gap: 0.45rem;
  align-items: end;
}

.rai-assistant-form textarea[data-rai-assistant-input] {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 3.2rem;
  max-height: 5.75rem;
  resize: vertical;
  border-radius: 10px;
  line-height: 1.35;
}

.rai-assistant-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.rai-assistant-tool {
  display: grid;
  place-items: center;
  width: 2.35rem;
  min-height: 2.35rem;
  padding: 0;
  border: 1px solid rgba(17, 17, 22, 0.1);
  border-radius: 10px;
  color: #111116;
  background: linear-gradient(180deg, #fff 0%, #f1f1f4 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 8px 18px rgba(17, 17, 22, 0.06);
}

.rai-assistant-tool svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rai-assistant-form button[type="submit"] {
  justify-self: end;
  min-height: 2.35rem;
  min-width: 7.4rem;
  border-radius: 10px;
}

.rai-assistant-tool.is-recording {
  color: #fff;
  border-color: #b91c1c;
  background: #b91c1c;
}

.rai-assistant-status {
  min-height: 1rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

@keyframes assistant-launcher-glow {
  0%,
  70%,
  100% {
    opacity: 0;
    transform: scale(1);
  }

  84% {
    opacity: 0.28;
    transform: scale(1.48);
  }

  94% {
    opacity: 0.06;
    transform: scale(1.85);
  }
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: var(--page);
}

.login-shell {
  width: min(100% - 2rem, 430px);
}

.login-panel {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(16, 16, 20, 0.08);
}

.login-brand {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  margin-bottom: 1rem;
}

.login-brand strong,
.login-brand span {
  display: block;
}

.login-brand span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.login-panel h1 {
  margin: 0 0 1rem;
  font-size: 1.8rem;
}

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

  .crm-sidebar {
    position: static;
    width: 100%;
    min-width: 0;
    height: auto;
  }

  .sidebar-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid,
  .sensor-strip,
  .period-grid,
  .analytics-grid,
  .analytics-columns,
  .settings-form,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .finder-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .report-action-board {
    grid-template-columns: 1fr;
  }

  .delete-signal-form,
  .source-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .report-action-widget-wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recommendations-filter-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto auto;
  }

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

  .source-panel {
    padding: 0;
    border-left: 0;
  }

  .compact-meta-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .exchange-card-head {
    flex-direction: column;
  }

  .exchange-badge {
    align-self: flex-start;
  }
}

@media (max-width: 640px) {
  body {
    background: #f2f2f4;
  }

  .crm-main {
    gap: 0.72rem;
    padding: 0.72rem 0.75rem 2rem;
  }

  .crm-sidebar {
    gap: 0.58rem;
    padding: 0.72rem;
  }

  .brand-box {
    min-height: 64px;
  }

  .brand-mark {
    flex-basis: 46px;
    width: 46px;
    height: 46px;
  }

  .sidebar-nav {
    grid-template-columns: 1fr;
    gap: 0.36rem;
  }

  .nav-link {
    min-height: 44px;
    padding: 0.48rem 0.6rem;
  }

  .page-header {
    padding: 0.9rem;
  }

  .page-header h1 {
    font-size: 1.78rem;
  }

  .panel-head {
    display: grid;
    gap: 0.62rem;
    align-items: start;
  }

  .panel-head .button-link {
    justify-self: stretch;
  }

  .finder-metrics {
    grid-template-columns: 1fr;
  }

  .recommendations-filter-bar {
    grid-template-columns: 1fr 1fr;
  }

  .recommendations-filter-bar label {
    grid-column: 1 / -1;
  }

  .workspace-panel,
  .stat-card,
  .analytics-card,
  .analytics-columns article,
  .period-grid article,
  .finder-metrics div,
  .source-panel,
  .report-card {
    border-radius: 8px;
  }

  .source-panel-head {
    grid-template-columns: 1fr;
  }

  .source-panel-head strong {
    justify-self: start;
    max-width: 100%;
  }

  .compact-meta-list {
    grid-template-columns: 1fr;
  }

  .analytics-row {
    align-items: stretch;
  }

  .analytics-row strong {
    max-width: 52%;
  }

  .responsive-table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table th,
  .responsive-table td {
    display: block;
  }

  .responsive-table {
    border: 0;
    background: transparent;
  }

  .responsive-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .responsive-table tr {
    margin-bottom: 0.62rem;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .responsive-table td {
    display: grid;
    grid-template-columns: minmax(104px, 0.38fr) minmax(0, 0.62fr);
    gap: 0.65rem;
    align-items: center;
    min-height: 42px;
    padding: 0.58rem 0.68rem;
    border-bottom: 1px solid var(--line);
    white-space: normal;
  }

  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 900;
    line-height: 1.2;
    text-transform: uppercase;
  }

  .responsive-table .cell-value {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .alert-table .cell-value small {
    display: block;
    margin-top: 0.28rem;
    color: var(--muted);
    line-height: 1.25;
  }

  .responsive-table td:last-child {
    border-bottom: 0;
  }

  .alert-payload-row td {
    display: grid;
  }

  .alert-payload-row td::before {
    align-self: start;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  pre {
    max-height: 260px;
    overflow: auto;
  }

  .rai-signature {
    display: none;
  }

  .rai-assistant {
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .rai-assistant-launcher {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
    max-width: 46px;
    max-height: 46px;
    border-radius: 13px;
  }

  .rai-assistant-launcher::before {
    inset: -6px;
    border-radius: 17px;
  }

  .rai-assistant-launcher img {
    width: 28px;
    height: 27px;
    max-width: 28px;
    max-height: 27px;
  }

  .rai-assistant-panel {
    width: calc(100vw - 1.5rem);
    max-height: calc(100vh - 6rem);
  }

  .rai-assistant-messages {
    min-height: 150px;
    max-height: 280px;
  }

  .rai-assistant-form textarea[data-rai-assistant-input] {
    min-height: 3rem;
  }

  .rai-assistant-form button[type="submit"] {
    min-width: 7.8rem;
  }

  .report-widget-grid,
  .report-action-widget-wide {
    grid-template-columns: 1fr;
  }

  .report-action-widget-cta.report-action-widget-wide,
  .report-action-widget-cta.report-action-widget-wide button {
    min-width: 0;
  }
}

@media (max-width: 1180px) {
  .recommendations-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .recommendations-table {
    min-width: 0;
  }

  .recommendations-table,
  .recommendations-table thead,
  .recommendations-table tbody,
  .recommendations-table tr,
  .recommendations-table th,
  .recommendations-table td {
    display: block;
  }

  .recommendations-table {
    border: 0;
    background: transparent;
  }

  .recommendations-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .recommendations-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin-bottom: 0.62rem;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .recommendations-table td {
    display: grid;
    grid-template-columns: minmax(96px, 0.42fr) minmax(0, 0.58fr);
    gap: 0.55rem;
    align-items: center;
    min-height: 42px;
    padding: 0.58rem 0.68rem;
    border-bottom: 1px solid var(--line);
    white-space: normal;
  }

  .recommendations-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 900;
    line-height: 1.2;
    text-transform: uppercase;
  }

  .recommendations-table td:nth-last-child(-n + 2) {
    border-bottom: 0;
  }
}

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

  .recommendations-table td:nth-last-child(2) {
    border-bottom: 1px solid var(--line);
  }
}
