:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-strong: #101418;
  --text: #13171c;
  --muted: #67717d;
  --line: #d9e0e7;
  --buy: #08795f;
  --sell: #b42318;
  --wait: #9a650b;
  --accent: #234f9f;
  --gold: #b98b16;
  --shadow: 0 18px 45px rgba(20, 28, 38, 0.08);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(16, 20, 24, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(16, 20, 24, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
}

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

a.button {
  text-decoration: none;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.site-titlebar {
  display: flex;
  justify-content: center;
  padding: 18px 0 22px;
  margin-bottom: 14px;
  text-align: center;
}

.site-titlebar h1 {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0;
  color: var(--text);
  font-size: 2.15rem;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0;
}

.admin-linkbar {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 14px;
}

.site-titlebar h1::after {
  position: absolute;
  right: 50%;
  bottom: -10px;
  width: 72%;
  height: 3px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--accent), var(--buy), transparent);
  border-radius: 999px;
  transform: translateX(50%);
  animation: title-sweep 2.8s ease-in-out infinite;
}

.title-signal {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: inset 0 0 0 6px rgba(35, 79, 159, 0.08);
  animation: title-pulse 2.2s ease-in-out infinite;
}

.title-signal::before,
.title-signal::after {
  position: absolute;
  content: "";
  background: var(--buy);
  border-radius: 999px;
}

.title-signal::before {
  right: 6px;
  bottom: 7px;
  width: 5px;
  height: 10px;
  animation: signal-rise 1.8s ease-in-out infinite;
}

.title-signal::after {
  right: 15px;
  bottom: 7px;
  width: 5px;
  height: 16px;
  animation: signal-rise 1.8s ease-in-out 0.25s infinite;
}

@keyframes title-pulse {
  0%,
  100% {
    transform: translateY(0);
    box-shadow: inset 0 0 0 6px rgba(35, 79, 159, 0.08), 0 0 0 0 rgba(35, 79, 159, 0.18);
  }

  50% {
    transform: translateY(-2px);
    box-shadow: inset 0 0 0 6px rgba(35, 79, 159, 0.08), 0 0 0 9px rgba(35, 79, 159, 0);
  }
}

@keyframes signal-rise {
  0%,
  100% {
    transform: scaleY(0.72);
    transform-origin: bottom;
  }

  50% {
    transform: scaleY(1.12);
    transform-origin: bottom;
  }
}

@keyframes title-sweep {
  0%,
  100% {
    opacity: 0.45;
    transform: translateX(50%) scaleX(0.82);
  }

  50% {
    opacity: 1;
    transform: translateX(50%) scaleX(1);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  place-items: center;
  color: #ffffff;
  background: var(--panel-strong);
  border-radius: 8px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.2rem, 1rem + 0.7vw, 1.9rem);
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.clock {
  min-width: 112px;
  padding: 9px 12px;
  color: #ffffff;
  background: var(--panel-strong);
  border-radius: 8px;
}

.clock span,
.engine-tile span,
.block-label,
.pair-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.4;
}

.clock span {
  color: rgba(255, 255, 255, 0.68);
}

.clock strong {
  display: block;
  margin-top: 2px;
  font-size: 1.15rem;
  line-height: 1;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
  white-space: nowrap;
}

.button:hover {
  transform: translateY(-1px);
  border-color: #aab6c3;
}

.button:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(35, 79, 159, 0.24);
  outline-offset: 2px;
}

.button svg,
.brand-mark svg {
  width: 18px;
  height: 18px;
}

.button-primary {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.button-ghost {
  background: #f7f9fb;
}

.button-icon {
  width: 42px;
  flex: 0 0 42px;
  padding: 0;
  background: #f7f9fb;
}

.pwa-prompt {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  width: min(420px, calc(100% - 32px));
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-right: 5px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 20px 45px rgba(16, 20, 24, 0.14);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: pwa-slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes pwa-slide-up {
  from {
    transform: translateY(60px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.pwa-prompt strong {
  display: block;
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--text);
}

.pwa-prompt p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.pwa-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.pwa-actions .button {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 700;
}

.pwa-actions .button-icon {
  flex: 0 0 42px;
  width: 42px;
  padding: 0;
  background: #f7f9fb;
}

@media (max-width: 520px) {
  .pwa-prompt {
    right: 16px;
    left: 16px;
    bottom: 16px;
    width: auto;
  }
}

/* iOS Safari Custom Installation Guide */
.ios-guide-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(16, 20, 24, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 2000;
  animation: ios-fade-in 0.3s ease forwards;
}

@keyframes ios-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ios-guide-modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: min(440px, calc(100% - 32px));
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.25);
  padding: 24px;
  position: relative;
  animation: ios-zoom-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  direction: rtl;
}

@keyframes ios-zoom-in {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.ios-guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.ios-guide-header strong {
  font-size: 1.22rem;
  font-weight: 800;
  color: var(--text);
}

.ios-guide-close {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  padding: 6px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: background 0.2s, color 0.2s;
}

.ios-guide-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

.ios-guide-body p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.98rem;
}

.ios-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 16px;
}

.ios-steps li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  line-height: 1.6;
  font-size: 0.98rem;
  color: var(--text);
}

.step-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  background: var(--accent);
  color: #ffffff;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.9rem;
}

.inline-icon {
  display: inline-flex;
  align-self: center;
  vertical-align: middle;
  width: 20px;
  height: 20px;
  margin: 0 4px;
  color: var(--accent);
}

.lucide-icon {
  width: 18px;
  height: 18px;
}

.login-shell {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

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

.login-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  color: #ffffff;
  background: var(--panel-strong);
  border-radius: 8px;
}

.login-mark svg {
  width: 22px;
  height: 22px;
}

.login-card h1 {
  margin: 14px 0 18px;
  font-size: 1.55rem;
  line-height: 1.25;
  letter-spacing: 0;
}

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

.login-card label {
  color: #27313b;
  font-weight: 800;
}

.login-card input {
  min-height: 46px;
  width: 100%;
  padding: 0 12px;
  color: var(--text);
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-error {
  min-height: 24px;
  margin: 0;
  color: var(--sell);
  font-weight: 700;
  line-height: 1.5;
}

.engine-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.engine-strip-bottom {
  margin-top: 14px;
  margin-bottom: 0;
}

.engine-tile {
  min-height: 98px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-right: 5px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(16, 20, 24, 0.05);
}

.engine-tile strong {
  display: block;
  margin: 6px 0 2px;
  font-size: 1.12rem;
}

.engine-tile small {
  color: var(--muted);
  line-height: 1.5;
}

.engine-tile[data-engine="real-yields"] {
  border-right-color: var(--gold);
}

.engine-tile[data-engine="liquidity"] {
  border-right-color: var(--accent);
}

.engine-tile[data-engine="volatility"] {
  border-right-color: #7550a8;
}

.engine-tile[data-engine="positioning"] {
  border-right-color: var(--buy);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 420px);
  gap: 14px;
  align-items: start;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
  gap: 14px;
  align-items: start;
}

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

.signal-card {
  display: flex;
  min-height: 222px;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.pair-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.signal-action {
  display: inline-flex;
  align-items: center;
  min-width: 86px;
  min-height: 38px;
  justify-content: center;
  padding: 0 12px;
  color: #ffffff;
  border-radius: 8px;
  font-size: 1.35rem;
  line-height: 1;
}

.signal-action.is-buy {
  background: var(--buy);
}

.signal-action.is-sell {
  background: var(--sell);
}

.signal-action.is-wait {
  color: #3b2904;
  background: #f7d893;
}

.confidence-meter {
  display: grid;
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  place-items: center;
  color: var(--text);
  background:
    radial-gradient(closest-side, #ffffff 71%, transparent 72% 100%),
    conic-gradient(var(--meter-color, var(--wait)) var(--meter-value, 0%), #e5ebf0 0);
  border-radius: 50%;
}

.confidence-value {
  font-size: 1rem;
  font-weight: 800;
}

.confidence-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  margin: 22px 0 16px;
  background: #e8edf2;
  border-radius: 999px;
}

.confidence-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--meter-color, var(--wait));
  border-radius: inherit;
  transition: width 220ms ease;
}

.signal-reason {
  min-height: 58px;
  margin: 0;
  color: #27313b;
  font-size: 1rem;
  line-height: 1.75;
}

.market-panel {
  display: grid;
  gap: 14px;
}

.panel-block,
.composer {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(16, 20, 24, 0.05);
}

.panel-block strong {
  display: block;
  margin-top: 7px;
  font-size: 1.28rem;
}

.panel-block p {
  margin: 8px 0 0;
  color: #2c3642;
  line-height: 1.7;
}

.risk-block {
  border-right: 5px solid var(--sell);
}

.composer {
  display: grid;
  gap: 12px;
}

.composer-large {
  min-height: 640px;
}

.composer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.composer label {
  color: var(--text);
  font-weight: 800;
}

select {
  min-width: 132px;
  min-height: 38px;
  padding: 0 10px;
  color: var(--text);
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

textarea {
  min-height: 230px;
  resize: vertical;
  width: 100%;
  padding: 12px;
  color: var(--text);
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.65;
}

.textarea-large {
  min-height: 460px;
}

.editor-side {
  display: grid;
  gap: 14px;
}

.status-line {
  min-height: 42px;
  margin: 0;
  padding: 10px 12px;
  color: #2c3642;
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 50%;
  bottom: 22px;
  transform: translateX(50%);
  z-index: 20;
  padding: 10px 14px;
  color: #ffffff;
  background: var(--panel-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

@media (max-width: 1080px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

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

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

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

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 10px;
  }

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

  .top-actions {
    width: 100%;
  }



  .clock,
  .button {
    flex: 1 1 150px;
  }

  .engine-strip,
  .signals,
  .market-panel,
  .editor-side {
    grid-template-columns: 1fr;
  }

  .signal-card {
    min-height: 196px;
  }
}

@media (max-width: 520px) {
  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .signal-head,
  .composer-head {
    flex-direction: column;
    align-items: stretch;
  }

  .confidence-meter {
    align-self: flex-start;
  }

  select {
    width: 100%;
  }
}

/* Recommendation History Modal Styles */
.history-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(16, 20, 24, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 2000;
  animation: ios-fade-in 0.3s ease forwards;
}

.history-modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: min(520px, calc(100% - 32px));
  max-height: 90vh;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  animation: ios-zoom-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  direction: rtl;
  overflow: hidden;
}

.history-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.history-modal-header strong {
  font-size: 1.22rem;
  font-weight: 800;
  color: var(--text);
}

.history-modal-close {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  padding: 6px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: background 0.2s, color 0.2s;
}

.history-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

.history-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.history-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  gap: 16px;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(35, 79, 159, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.history-timeline-section {
  margin-top: 24px;
}

.history-timeline-section h4 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  border-right: 4px solid var(--accent);
  padding-right: 10px;
}

.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  padding-right: 16px;
  border-right: 2px solid var(--line);
  margin-right: 8px;
}

.timeline-item {
  position: relative;
}

.timeline-dot {
  position: absolute;
  right: -23px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2.5px solid var(--panel);
  z-index: 2;
}

.timeline-dot.buy { background: #2ec4b6; box-shadow: 0 0 8px rgba(46, 196, 182, 0.6); }
.timeline-dot.sell { background: #e71d36; box-shadow: 0 0 8px rgba(231, 29, 54, 0.6); }
.timeline-dot.wait { background: #ff9f1c; box-shadow: 0 0 8px rgba(255, 159, 28, 0.6); }

.timeline-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.timeline-date {
  font-size: 0.85rem;
  color: var(--muted);
}

.timeline-action-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
}

.timeline-action-badge.buy { background: rgba(46, 196, 182, 0.1); color: #2ec4b6; }
.timeline-action-badge.sell { background: rgba(231, 29, 54, 0.1); color: #e71d36; }
.timeline-action-badge.wait { background: rgba(255, 159, 28, 0.1); color: #ff9f1c; }

.timeline-reason {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.5;
  background: #f7f9fb;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 0;
}

.no-history-msg {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.no-history-msg p {
  margin: 6px 0;
}
