﻿:root {
  --bg-base: #f3f7ed;
  --bg-soft: #e8efe2;
  --ink-900: #101a23;
  --ink-700: #2a3b49;
  --ink-500: #5c7181;
  --ink-300: #9bb0bf;
  --panel-bg: rgba(255, 255, 255, 0.72);
  --panel-border: rgba(16, 26, 35, 0.11);
  --shadow: 0 20px 50px rgba(17, 34, 51, 0.12);
  --accent: #0f9d8a;
  --accent-strong: #0a7f6f;
  --accent-soft: rgba(15, 157, 138, 0.15);
  --danger: #d3495c;
  --danger-soft: rgba(211, 73, 92, 0.14);
  --warn: #c98628;
  --warn-soft: rgba(201, 134, 40, 0.15);
  --radius-xl: 24px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  color: var(--ink-900);
  background: linear-gradient(145deg, var(--bg-base) 0%, #edf4f9 45%, var(--bg-soft) 100%);
  line-height: 1.4;
  overflow-x: hidden;
}

.mono {
  font-family: 'IBM Plex Mono', Consolas, monospace;
}

.bg-layer {
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  filter: blur(0.2px);
}

.bg-layer-a {
  top: -100px;
  left: -80px;
  width: 440px;
  height: 440px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 157, 138, 0.18) 0%, rgba(15, 157, 138, 0) 68%);
}

.bg-layer-b {
  top: 26%;
  right: -140px;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 122, 175, 0.16) 0%, rgba(16, 122, 175, 0) 64%);
}

.bg-layer-c {
  bottom: -120px;
  left: 28%;
  width: 480px;
  height: 380px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 134, 40, 0.14) 0%, rgba(201, 134, 40, 0) 70%);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1600px, calc(100% - 32px));
  margin: 22px auto 26px;
  display: grid;
  gap: 16px;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: panel-in 460ms ease both;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  padding: 20px 22px;
}

.brand-wrap {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #0d7f72;
  border: 1px solid rgba(13, 127, 114, 0.24);
  background: linear-gradient(145deg, rgba(15, 157, 138, 0.23), rgba(15, 157, 138, 0.06));
}

.brand-icon svg {
  width: 26px;
  height: 26px;
}

.brand-title {
  margin: 0;
  font-size: clamp(1.36rem, 2vw, 1.8rem);
  letter-spacing: 0.01em;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--ink-700);
  font-size: 0.95rem;
}

.brand-meta {
  margin: 4px 0 0;
  color: var(--ink-500);
  font-size: 0.78rem;
}

.ws-state {
  font-weight: 700;
}

.ws-live {
  color: var(--accent-strong);
}

.ws-warn {
  color: var(--warn);
}

.ws-error {
  color: var(--danger);
}

.actions-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bot-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  padding: 9px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.pill-live {
  background: rgba(15, 157, 138, 0.12);
  border-color: rgba(15, 157, 138, 0.28);
  color: #0b6e62;
}

.pill-paused {
  background: var(--warn-soft);
  border-color: rgba(201, 134, 40, 0.3);
  color: #8f5a12;
}

.pill-unknown {
  background: rgba(92, 113, 129, 0.14);
  color: #456071;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-live {
  background: #0f9d8a;
  box-shadow: 0 0 0 0 rgba(15, 157, 138, 0.55);
  animation: dot-pulse 1.6s ease-out infinite;
}

.dot-paused {
  background: #c98628;
}

.dot-off {
  background: #7f95a5;
}

.btn {
  border: 1px solid transparent;
  border-radius: 11px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 200ms ease, background 180ms ease, border-color 180ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  color: white;
  background: linear-gradient(135deg, #0f9d8a, #0a7f6f);
  box-shadow: 0 8px 20px rgba(10, 127, 111, 0.22);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 10px 24px rgba(10, 127, 111, 0.28);
}

.btn-secondary {
  color: white;
  background: linear-gradient(135deg, #1b8fcb, #0b6692);
  box-shadow: 0 8px 18px rgba(11, 102, 146, 0.24);
}

.btn-ghost {
  color: var(--ink-700);
  background: rgba(255, 255, 255, 0.65);
  border-color: rgba(16, 26, 35, 0.16);
}

.hero-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1.15fr 1fr;
}

.total-panel,
.chart-panel,
.config-panel,
.events-panel {
  padding: 18px 20px;
}

.kicker {
  margin: 0;
  color: var(--ink-500);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.upnl-row {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.upnl-value {
  margin: 0;
  font-size: clamp(1.92rem, 3.2vw, 3.1rem);
  line-height: 1.08;
}

.upnl-percent {
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  font-weight: 600;
}

.tone-positive {
  color: #0b836f;
}

.tone-negative {
  color: #b53a4e;
}

.tone-neutral {
  color: #475f70;
}

.totals-grid {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed rgba(16, 26, 35, 0.16);
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.totals-grid .label {
  display: block;
  font-size: 0.69rem;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 4px;
}

.totals-grid strong {
  font-size: 0.93rem;
  color: var(--ink-900);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head.compact {
  margin-bottom: 8px;
}

.panel-head h3 {
  margin: 0;
  font-size: 1.04rem;
  line-height: 1.25;
}

.muted {
  margin: 3px 0 0;
  color: var(--ink-500);
  font-size: 0.84rem;
}

.chart-wrap {
  position: relative;
  height: 292px;
}

.workspace-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.95fr) minmax(340px, 1fr);
}

.workspace-grid > .panel {
  padding: 14px 18px 16px;
  min-width: 0;
}

.table-wrap {
  overflow: auto;
}

.table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
}

.table th,
.table td {
  padding: 10px 12px;
  font-size: 0.82rem;
}

.table thead th {
  position: sticky;
  top: 0;
  background: rgba(245, 249, 252, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
  font-size: 0.7rem;
  z-index: 1;
}

.table tbody tr {
  transition: background 150ms ease;
}

.table tbody tr:hover {
  background: rgba(16, 122, 175, 0.08);
}

.table td {
  color: var(--ink-700);
  border-top: 1px solid rgba(16, 26, 35, 0.07);
}

.align-right {
  text-align: right;
}

.empty-cell,
.empty-list {
  text-align: center;
  color: var(--ink-500);
  padding: 20px 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  padding: 0 9px;
  background: rgba(15, 157, 138, 0.15);
  color: #0b6e62;
  font-size: 0.72rem;
  border: 1px solid rgba(15, 157, 138, 0.27);
}

.panel-body {
  display: grid;
  gap: 10px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.text-input {
  width: 100%;
  border-radius: 11px;
  border: 1px solid rgba(16, 26, 35, 0.18);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink-900);
  padding: 9px 11px;
  font-size: 0.87rem;
}

.text-input::placeholder {
  color: #7a8e9f;
}

.text-input:focus {
  outline: none;
  border-color: rgba(15, 157, 138, 0.55);
  box-shadow: 0 0 0 3px rgba(15, 157, 138, 0.15);
}

.whales-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  max-height: 248px;
  overflow: auto;
}

.whale-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(16, 26, 35, 0.11);
  background: rgba(255, 255, 255, 0.56);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.78rem;
}

.whale-row span {
  color: var(--ink-700);
}

.whale-row button {
  appearance: none;
  border: 0;
  background: transparent;
  color: #8a9cab;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px;
}

.whale-row button:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.form-note {
  min-height: 1.15rem;
  margin: 0;
  font-size: 0.77rem;
  color: var(--ink-500);
}

.form-note--error {
  color: var(--danger);
}

.form-note--success {
  color: var(--accent-strong);
}

.config-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--ink-700);
}

.toggle-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.toggle-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(16, 26, 35, 0.1);
  padding: 8px 10px;
  font-size: 0.8rem;
  color: var(--ink-700);
}

.toggle-item.subtle {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.45);
}

.checkbox {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(16, 26, 35, 0.3);
  display: inline-grid;
  place-items: center;
  background: #f7fafc;
  cursor: pointer;
}

.checkbox:checked {
  background: var(--accent);
  border-color: var(--accent-strong);
}

.checkbox:checked::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #ffffff;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
}

.checkbox:focus-visible {
  outline: 2px solid rgba(15, 157, 138, 0.45);
  outline-offset: 2px;
}

.config-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-row {
  display: inline-flex;
  gap: 8px;
}

.events-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  max-height: 320px;
  overflow: auto;
}

.event-row {
  display: grid;
  grid-template-columns: auto 130px 1fr;
  gap: 10px;
  align-items: baseline;
  border-radius: 10px;
  padding: 7px 8px;
  transition: background 130ms ease;
}

.event-row:hover {
  background: rgba(16, 122, 175, 0.08);
}

.event-time {
  color: var(--ink-500);
  font-size: 0.73rem;
}

.event-kind {
  color: #0b6692;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.event-text {
  color: var(--ink-700);
  font-size: 0.79rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footer-note {
  text-align: center;
  margin: 0;
  color: var(--ink-500);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.table-upnl {
  text-align: right;
  font-weight: 600;
}

.table-upnl small {
  display: block;
  font-size: 0.67rem;
  opacity: 0.8;
}

.table-upnl.positive {
  color: #0b836f;
}

.table-upnl.negative {
  color: #b53a4e;
}

.table-upnl.neutral {
  color: #4f6273;
}

.pending-tag {
  margin-left: 4px;
  color: #9a6b17;
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

@keyframes panel-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes dot-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(15, 157, 138, 0.55);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(15, 157, 138, 0);
  }
}

.panel:nth-child(1) {
  animation-delay: 40ms;
}

.panel:nth-child(2) {
  animation-delay: 90ms;
}

.panel:nth-child(3) {
  animation-delay: 130ms;
}

.panel:nth-child(4) {
  animation-delay: 170ms;
}

.panel:nth-child(5) {
  animation-delay: 210ms;
}

@media (max-width: 1120px) {
  .hero-grid,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .workspace-grid > .panel {
    padding: 14px 14px 16px;
  }

  .table {
    min-width: 700px;
  }

  .chart-wrap {
    height: 260px;
  }

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

@media (max-width: 860px) {
  .shell {
    width: calc(100% - 22px);
    margin-top: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions-wrap {
    width: 100%;
    justify-content: space-between;
  }

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

  .event-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .event-text {
    white-space: normal;
  }
}

@media (max-width: 640px) {
  .brand-icon {
    width: 42px;
    height: 42px;
  }

  .brand-subtitle {
    font-size: 0.88rem;
  }

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

  .input-row {
    flex-direction: column;
  }

  .btn-row {
    width: 100%;
  }

  .btn-row .btn {
    flex: 1;
  }

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

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(92, 113, 129, 0.35);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(92, 113, 129, 0.58);
}
