* {
  box-sizing: border-box;
}

:root {
  --bg-page: #e9edf3;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --ink: #0b1220;
  --muted: #64748b;
  --line: #d9e2ef;
  --gold: #d6a10b;
  --gold-soft: #fff3bf;
  --green: #08a045;
  --green-bright: #6aff00;
  --blue: #229ed9;
  --red: #ff2d15;
  --shadow-soft: 0 14px 34px rgba(15, 23, 42, 0.12);
  --shadow-lift: 0 18px 44px rgba(15, 23, 42, 0.18);
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), transparent 32%),
    repeating-linear-gradient(135deg, rgba(15, 23, 42, 0.035) 0 1px, transparent 1px 18px),
    var(--bg-page);
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

body.auth-locked .app-shell {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: calc(100vw - 16px);
  height: calc(100vh - 16px);
  margin: 8px;
  background: linear-gradient(180deg, #f8fafc 0%, #eef3f8 100%);
  border: 1px solid rgba(217, 226, 239, 0.96);
  border-radius: 14px;
  overflow: visible;
  box-shadow: var(--shadow-lift);
}

.toolbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 6px 10px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.symbol-title {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 218px;
  min-width: 218px;
  gap: 8px;
  color: #111827;
  font-size: 16px;
  line-height: 1;
}

.symbol-title strong {
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
}

.symbol-selector {
  width: 138px;
  min-height: 34px;
  padding: 0 24px 0 8px;
  border: 0;
  outline: 0;
  appearance: none;
  background: #f5f6f8;
  color: #111827;
  font: 800 15px/1 Arial, sans-serif;
  cursor: pointer;
  border-radius: 5px;
}

.symbol-title::after {
  content: "⌄";
  position: absolute;
  left: 195px;
  top: 9px;
  color: #6b7280;
  font-size: 14px;
  font-weight: 900;
  pointer-events: none;
}

.symbol-selector:focus-visible {
  outline: 2px solid #229ed9;
  outline-offset: 3px;
  border-radius: 4px;
}

.coin-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, #fff5b8 0 16%, transparent 17%),
    linear-gradient(135deg, #ffd84a 0%, #d6a10b 48%, #916000 100%);
  box-shadow: inset 0 -2px 4px rgba(72, 43, 0, 0.32), 0 0 0 3px rgba(218, 165, 32, 0.16), 0 8px 20px rgba(145, 96, 0, 0.22);
}

.coin-mark::before {
  content: "Au";
  position: absolute;
  color: #4b3100;
  font: 900 10px/1 Arial, sans-serif;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.coin-mark::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 5px;
  height: 2px;
  border-radius: 999px;
  background: rgba(75, 49, 0, 0.52);
}

.chart-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  margin: 0 auto;
}

.toolbar-token-input {
  height: 32px;
  width: 132px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, background 140ms ease;
}

.toolbar-token-input::placeholder {
  color: #94a3b8;
  font-weight: 500;
}

.toolbar-token-input:focus {
  border-color: var(--green);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(8, 160, 69, 0.14), 0 8px 20px rgba(8, 160, 69, 0.08);
  transform: translateY(-1px);
}

.account-actions {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 168px;
  justify-content: flex-end;
}

.account-name {
  max-width: 120px;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-button {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f5f8fc);
  color: var(--ink);
  padding: 0 10px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.account-button:hover {
  border-color: #94a3b8;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.timeframe-button,
.add-toggle-button,
.signal-filter-button,
.icon-button {
  display: inline-grid;
  place-items: center;
  height: 34px;
  min-width: 40px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #4b5563;
  font: 700 12px/1 Arial, sans-serif;
  cursor: pointer;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.timeframe-button:hover,
.add-toggle-button:hover,
.signal-filter-button:hover,
.icon-button:hover {
  border-color: #d1d5db;
  background: #f3f4f6;
  color: #111827;
  box-shadow: none;
  transform: none;
}

.timeframe-button.active,
.add-toggle-button.active,
.signal-filter.open .signal-filter-button {
  border-color: #d1d5db;
  background: #e5e7eb;
  color: #111827;
  box-shadow: none;
}

.add-toggle-button {
  min-width: 136px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.signal-filter {
  position: relative;
  display: inline-flex;
}

.signal-filter-button {
  min-width: 104px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  color: #374151;
  background: #f5f6f8;
}

.signal-filter-menu {
  position: fixed;
  /* Fallback only — JS sets an exact px "top" once opened. See the note on
     .control-hidden: with position:fixed, a % top is relative to the whole
     viewport, not the toolbar, so it must stay a fixed px guess. */
  top: 88px;
  right: 0;
  z-index: 9999;
  display: grid;
  gap: 7px;
  min-width: 168px;
  padding: 10px;
  border: 1px solid rgba(217, 226, 239, 0.94);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(12px);
}

.signal-filter-menu.hidden {
  display: none;
}

.signal-filter-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  color: #0f172a;
  font: 800 12px/1.2 Arial, sans-serif;
  cursor: pointer;
  user-select: none;
}

.signal-filter-menu input {
  width: 15px;
  height: 15px;
  accent-color: #009900;
}

.icon-button {
  min-width: 34px;
  background: #ffffff;
  color: var(--ink);
  font-size: 19px;
}

.icon-button:hover {
  background: #f3f4f6;
}

.signal-toggle-button {
  border-radius: 5px;
}

.icon-button[disabled],
.timeframe-button[disabled],
.op-toggle-button[disabled] {
  cursor: wait;
  opacity: 0.55;
}

.control-hidden {
  position: fixed;
  /* Fallback position only (JS overrides this with an exact px value once the
     panel opens). NOTE: with position:fixed, "top: 100%" resolves against the
     viewport height, not the toolbar — so it must NOT be a percentage, or the
     panel renders below the visible screen (and can't be reached because the
     page can't scroll). Use a fixed px guess close to the toolbar height instead. */
  top: 88px;
  right: 18px;
  z-index: 10000;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(320px, 2fr) auto auto auto;
  align-items: start;
  gap: 10px;
  width: min(860px, calc(100vw - 36px));
  min-width: 0;
  max-height: min(72vh, 560px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  border: 1px solid rgba(217, 226, 239, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.2);
  backdrop-filter: blur(14px);
}

.control-hidden.hidden {
  display: none;
}

/* The settings panel is moved to body when opened. Keep it above every chart
   canvas regardless of the browser's stacking-context implementation. */
body > #advancedControlsPanel:not(.hidden) {
  position: fixed !important;
  top: 82px !important;
  right: 10px !important;
  left: 10px !important;
  bottom: auto !important;
  z-index: 2147483647 !important;
  width: auto !important;
  max-height: calc(100vh - 94px) !important;
  max-height: calc(100dvh - 94px) !important;
  overflow: auto !important;
  pointer-events: auto !important;
}

.control-hidden input,
.control-hidden select {
  height: 34px;
  min-width: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
  outline: none;
}

.control-hidden input:focus,
.control-hidden select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(8, 160, 69, 0.14);
}

#limitSelect,
#intervalSelect {
  display: none;
}

.market-feed-control {
  display: inline-flex;
  align-items: center;
  height: 34px;
  min-width: min(260px, 22vw);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.market-feed-control span {
  display: inline-grid;
  place-items: center;
  align-self: stretch;
  padding: 0 9px;
  background: linear-gradient(180deg, #eef7ef, #dff3e6);
  color: #14532d;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.market-feed-control #sourceSelect {
  height: 32px;
  min-width: 0;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.market-feed-control:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(8, 160, 69, 0.14);
}

.op-adjust-control {
  display: inline-flex;
  align-items: center;
  height: 34px;
  min-width: 146px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.op-adjust-control span {
  display: inline-grid;
  place-items: center;
  align-self: stretch;
  padding: 0 9px;
  background: linear-gradient(135deg, #047336, #08a045);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.op-adjust-control #opOffsetInput {
  display: block;
  width: 92px;
  min-width: 0;
  height: 32px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0 8px;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  box-shadow: none;
}

.op-adjust-control:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(8, 160, 69, 0.14);
}

.op-reset-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.op-reset-button:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}

.settings-toggle-button.active {
  border-color: var(--green);
  background: linear-gradient(135deg, #047336, #08a045);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(8, 160, 69, 0.22);
}

.level-visibility-control {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  min-width: 0;
  padding: 9px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
}

.level-visibility-control > span {
  display: inline-grid;
  place-items: center;
  min-height: 27px;
  padding: 0 9px;
  border-radius: 6px;
  background: linear-gradient(135deg, #047336, #08a045);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.level-visibility-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.level-visibility-grid label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 27px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.level-visibility-grid input {
  width: 14px;
  height: 14px;
  min-width: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: #009900;
  box-shadow: none;
}

input,
select {
  font: inherit;
}

.chart-frame {
  position: relative;
  min-height: 0;
  margin: 0 18px 18px;
  overflow: hidden;
  border: 1px solid rgba(8, 160, 69, 0.22);
  border-radius: 10px;
  background: #0b101a;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 18px 42px rgba(2, 6, 23, 0.28),
    0 0 0 1px rgba(214, 161, 11, 0.08);
}

#chart {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: #111722;
}

.marker-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.draw-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.chart-frame.drawing-active .draw-layer {
  pointer-events: auto;
  cursor: crosshair;
}

.level-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.level-badge {
  position: absolute;
  left: 0;
  min-width: 38px;
  height: 18px;
  padding: 2px 5px;
  transform: translateY(-50%);
  border-radius: 2px;
  color: #05070b;
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 14px;
  white-space: nowrap;
  text-shadow: none;
}

.level-badge.plain,
.level-badge.price {
  background: #eeeeee;
  color: #111111;
}

.level-badge.price {
  background: #777777;
  color: #ffffff;
}

.level-badge.diamond-line {
  background: #ffffff;
  color: #05070b;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.45);
}

.level-badge.pivot {
  background: #ff1493;
  color: #ffffff;
}

.level-badge.kcb {
  background: #c8f3ff;
  color: #111111;
}

.level-badge.mlp {
  background: #fff6a6;
  color: #111111;
}

.level-badge.lime {
  background: #7fff00;
}

.level-badge.yellow {
  background: #ffff00;
}

.level-badge.gold {
  background: #daa520;
}

.level-badge.orange {
  background: #f6a800;
}

.diamond-marker {
  position: absolute;
  width: 13px;
  height: 13px;
  border: 1px solid #0b0e11;
  transform: translate(-50%, -50%) rotate(45deg);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.24), 0 0 14px rgba(103, 246, 255, 0.22);
}

.diamond-buy {
  background: #67f6ff;
}

.diamond-add {
  background: #ffd199;
}

.diamond-add::before,
.diamond-add::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 11px;
  height: 2px;
  background: #7b3f00;
  border-radius: 999px;
  transform-origin: center;
}

.diamond-add::before {
  transform: translate(-50%, -50%) rotate(0deg);
}

.diamond-add::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.diamond-accumulation {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.32), 0 0 10px rgba(255, 255, 255, 0.72);
}

.buy-arrow-marker {
  position: absolute;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 28px;
  color: #00b300;
  font-family: Arial, sans-serif;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 1px #000000, 0 0 5px rgba(0, 179, 0, 0.65);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.buy-arrow-marker::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 18px solid #00b300;
  filter: drop-shadow(0 1px 1px #000000) drop-shadow(0 0 8px rgba(0, 179, 0, 0.72));
}

.sell-arrow-marker {
  position: absolute;
  display: inline-flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 2px;
  min-width: 32px;
  color: #ff2d15;
  font-family: Arial, sans-serif;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 1px #000000, 0 0 5px rgba(255, 45, 21, 0.65);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.sell-arrow-marker::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 18px solid #ff2d15;
  filter: drop-shadow(0 1px 1px #000000) drop-shadow(0 0 8px rgba(255, 45, 21, 0.72));
}

@keyframes markerPop {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.82);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.watermark {
  position: absolute;
  inset: 0;
  z-index: 2;
  color: rgba(205, 170, 85, 0.11);
  pointer-events: none;
}

.watermark strong {
  position: absolute;
  top: 31%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(42px, 7vw, 92px);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.watermark span {
  display: none;
}

.watermark::before,
.watermark::after {
  content: "KIM CHI VANG";
  position: absolute;
  color: rgba(205, 170, 85, 0.62);
  font-weight: 900;
  line-height: 1;
}

.watermark::before {
  top: 14px;
  right: 128px;
  font-size: 30px;
}

.watermark::after {
  left: 10px;
  bottom: 24px;
  font-size: 31px;
}

.pane-label {
  position: absolute;
  left: 50px;
  z-index: 6;
  color: #76ffad;
  font-family: Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
  text-shadow: 0 1px 0 #000;
}

.ksi-label {
  top: calc(71.4% + 4px);
}

.kcx-label {
  top: calc(85.7% + 4px);
}

.status-pill {
  position: absolute;
  right: 10px;
  bottom: 7px;
  z-index: 7;
  max-width: min(60vw, 560px);
  padding: 5px 9px;
  border: 1px solid rgba(106, 255, 0, 0.22);
  border-radius: 7px;
  background: rgba(2, 6, 23, 0.82);
  color: #e5e7eb;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  opacity: 1;
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.candle-countdown {
  position: absolute;
  right: 10px;
  bottom: 38px;
  z-index: 7;
  max-width: calc(100% - 20px);
  padding: 4px 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 6px;
  background: rgba(2, 6, 23, 0.78);
  color: #dbeafe;
  font: 700 11px/1.2 Consolas, monospace;
  letter-spacing: 0;
  pointer-events: none;
  white-space: nowrap;
}

.signal-notice {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 8;
  width: min(360px, calc(100% - 24px));
  max-height: min(68vh, 520px);
  overflow: auto;
  border: 1px solid rgba(79, 255, 158, 0.22);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(8, 16, 28, 0.96), rgba(2, 6, 23, 0.94));
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42), 0 0 24px rgba(34, 230, 111, 0.11);
  color: #f4f7fb;
  backdrop-filter: blur(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.signal-notice.signal-collapsed {
  display: none;
}

.signal-notice.signal-custom-position {
  right: auto;
  bottom: auto;
}

.signal-notice.signal-dragging {
  user-select: none;
  transition: none;
}

.signal-notice.signal-buy {
  border-left-color: var(--green-bright);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42), 0 0 28px rgba(106, 255, 0, 0.16);
}

.signal-notice.signal-sell {
  border-left-color: var(--red);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42), 0 0 28px rgba(255, 45, 21, 0.16);
}

.signal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent);
  cursor: move;
  touch-action: none;
}

.signal-head span {
  min-width: 0;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.signal-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  cursor: default;
}

.copy-signal-button,
.send-telegram-button,
.hide-signal-button,
.signal-toggle-button {
  flex: 0 0 auto;
  height: 27px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: #f3f4f6;
  color: #111827;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.hide-signal-button {
  background: rgba(255, 255, 255, 0.1);
  color: #f9fafb;
}

.send-telegram-button {
  border-color: rgba(34, 158, 217, 0.88);
  background: linear-gradient(135deg, #229ed9, #126ca1);
  color: #ffffff;
  box-shadow: 0 7px 18px rgba(34, 158, 217, 0.28);
}

.copy-signal-button {
  border-color: rgba(214, 161, 11, 0.56);
  background: linear-gradient(180deg, #fff7d6, #f3d676);
  color: #4b3100;
}

.copy-signal-button:hover,
.send-telegram-button:hover,
.hide-signal-button:hover,
.signal-toggle-button:hover {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.signal-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 92px;
  height: 32px;
  border-color: var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f5f8fc);
  color: var(--ink);
  padding: 0 10px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.signal-toggle-button::before {
  content: "";
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #020617;
  box-shadow: 0 0 0 2px rgba(2, 6, 23, 0.12);
}

.signal-toggle-button.signal-state-buy::before {
  background: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.16), 0 0 10px rgba(22, 163, 74, 0.45);
}

.signal-toggle-button.signal-state-sell::before {
  background: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.16), 0 0 10px rgba(220, 38, 38, 0.45);
}

.signal-toggle-button.signal-panel-open {
  border-color: #020617;
  background: linear-gradient(135deg, #020617, #0f2c1b);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.2);
}

.signal-toggle-button.signal-panel-open::before {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2), 0 0 10px currentColor;
}

.signal-toggle-button.hidden {
  display: inline-flex;
}

.auth-screen,
.session-kick,
.admin-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(8, 13, 28, 0.9), rgba(15, 23, 42, 0.72)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 18px);
  backdrop-filter: blur(14px);
}

.login-panel {
  display: grid;
  gap: 16px;
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid rgba(226, 232, 240, 0.88);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 26px 76px rgba(2, 6, 23, 0.42);
}

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

.login-logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #101827;
  color: #facc15;
  font-size: 14px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.34);
}

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

.login-brand strong {
  color: #0f172a;
  font-size: 14px;
  font-weight: 900;
}

.login-brand small {
  margin-top: 2px;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.login-eyebrow {
  display: block;
  margin-top: 4px;
  color: #b45309;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.login-panel h1 {
  margin: 6px 0 0;
  color: #0f172a;
  font-size: 31px;
  line-height: 1.1;
}

.login-panel p {
  margin: 8px 0 0;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.login-panel label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.login-panel input,
.create-user-form input,
.create-user-form select {
  height: 42px;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  padding: 0 12px;
  font: 800 13px/1 Arial, sans-serif;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.login-panel input:focus,
.create-user-form input:focus,
.create-user-form select:focus {
  border-color: #16a34a;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.14);
}

.login-panel button,
.session-kick button,
.create-user-form button,
.admin-head button,
.admin-user-actions button {
  height: 40px;
  border: 1px solid #020617;
  border-radius: 8px;
  background: #020617;
  color: #ffffff;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.login-panel button {
  height: 44px;
  margin-top: 2px;
  background: linear-gradient(135deg, #101827, #172033);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
}

.login-panel button:hover,
.session-kick button:hover,
.create-user-form button:hover,
.admin-head button:hover,
.admin-user-actions button:hover {
  transform: translateY(-1px);
}

.login-panel button[disabled],
.create-user-form button[disabled] {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.login-error,
.admin-error {
  min-height: 18px;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
}

.session-kick > div {
  width: min(360px, 100%);
  padding: 20px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
  color: #7f1d1d;
  box-shadow: 0 24px 64px rgba(127, 29, 29, 0.18);
}

.session-kick strong {
  display: block;
  font-size: 18px;
}

.session-kick p {
  margin: 8px 0 14px;
  color: #991b1b;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}

.admin-dialog {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  width: min(1040px, 100%);
  max-height: min(86vh, 760px);
  min-height: 0;
  overflow: hidden;
  padding: 18px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(2, 6, 23, 0.36);
}

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

.admin-panel {
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.admin-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.admin-head strong {
  display: block;
  color: #0f172a;
  font-size: 19px;
  font-weight: 900;
}

.admin-head span {
  display: block;
  margin-top: 4px;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.admin-head button,
.admin-user-actions button {
  border-color: #d9e2ef;
  background: #ffffff;
  color: #0f172a;
}

.create-user-form {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(130px, 1fr) 110px auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.admin-user-list {
  display: grid;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  padding-bottom: 4px;
  touch-action: pan-y;
  scrollbar-gutter: stable;
}

.admin-device-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  padding-bottom: 4px;
  touch-action: pan-y;
  scrollbar-gutter: stable;
}

.admin-user-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(180px, 1fr) minmax(140px, 0.8fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.admin-user-row strong {
  display: block;
  color: #0f172a;
  font-size: 14px;
}

.admin-user-row span,
.admin-user-row small {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-status.online strong::after {
  content: " online";
  display: inline-block;
  margin-left: 6px;
  color: #16a34a;
  font-size: 11px;
}

.admin-user-actions {
  display: inline-flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-user-actions button.danger {
  border-color: #fecaca;
  color: #b91c1c;
}

.admin-user-actions button[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

.signal-notice pre {
  margin: 0;
  padding: 10px 12px;
  color: #eef2ff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.signal-risk {
  padding: 8px 12px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffd199;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}

.signal-pulse {
  animation: signalPulse 1.8s ease-out;
}

@keyframes signalPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.42), 0 16px 40px rgba(0, 0, 0, 0.34);
    transform: translateY(-3px);
  }
  100% {
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.34);
    transform: translateY(0);
  }
}

.analysis {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid #242b38;
  background: #242b38;
}

.analysis div {
  min-width: 0;
  padding: 8px 10px;
  background: #111820;
}

.analysis span {
  display: block;
  color: #8792a5;
  font-size: 11px;
  font-weight: 700;
}

.analysis strong {
  display: block;
  margin-top: 3px;
  color: #e5e7eb;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .toolbar {
    position: relative;
    min-height: 54px;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding: 8px;
    padding-top: max(8px, env(safe-area-inset-top));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: 0;
  }

  .toolbar::-webkit-scrollbar {
    display: none;
  }

  .symbol-title {
    position: sticky;
    left: 0;
    z-index: 5;
    flex: 0 0 auto;
    min-width: 0;
    padding-right: 8px;
    font-size: 15px;
    background: #ffffff;
  }

  .symbol-title::after {
    left: auto;
    right: 16px;
  }

  .symbol-selector {
    width: 112px;
    font-size: 14px;
  }

  .control-hidden {
    top: 64px;
    left: 12px;
    right: 12px;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 2fr) auto auto auto;
    width: auto;
    max-height: min(72vh, 560px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .control-hidden input,
  .control-hidden select {
    font-size: 16px;
  }

  .chart-frame {
    height: auto;
    min-height: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  #chart {
    left: 0;
    right: 0;
  }

  .chart-actions {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 5px;
  }

  .account-actions {
    flex: 0 0 auto;
    min-width: 0;
    margin-left: 4px;
  }

  .timeframe-button,
  .add-toggle-button,
  .signal-filter-button,
  .icon-button {
    height: 36px;
    min-width: 38px;
  }

  .add-toggle-button,
  .signal-filter-button {
    min-width: 128px;
  }

  .market-feed-control {
    flex: 0 0 220px;
    min-width: 220px;
  }

  .op-adjust-control {
    flex: 0 0 146px;
  }

  .toolbar-token-input {
    width: 108px;
    font-size: 16px;
  }

  .watermark::before {
    right: 86px;
    font-size: 18px;
  }

  .watermark::after {
    left: 12px;
    bottom: 16px;
    font-size: 18px;
  }

  .watermark strong {
    font-size: 42px;
    opacity: 0.55;
  }

  .create-user-form,
  .admin-user-row {
    grid-template-columns: 1fr;
  }

  .admin-user-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}






@media (max-width: 620px) {
  .toolbar {
    position: relative;
    align-items: center;
    min-height: 50px;
  }

  .chart-actions {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding: 4px;
  }

  .timeframe-button,
  .icon-button,
  .signal-filter-button,
  .signal-toggle-button,
  .settings-toggle-button {
    flex: 0 0 auto;
  }

  .account-actions {
    flex: 0 0 auto;
    gap: 5px;
  }

  .account-name {
    max-width: 72px;
  }

  .account-button {
    height: 32px;
    padding: 0 8px;
  }

  .control-hidden {
    top: calc(100% + 4px);
    left: 6px;
    right: 6px;
    grid-template-columns: 1fr;
    width: auto;
    max-height: calc(100vh - 104px);
    max-height: calc(100dvh - 104px);
  }

  .control-hidden input,
  .control-hidden select {
    height: 40px;
    font-size: 16px;
  }

  .market-feed-control {
    width: 100%;
    min-width: 0;
  }

  .op-adjust-control {
    width: 100%;
  }

  .toolbar-token-input {
    width: 92px;
  }

  .op-adjust-control #opOffsetInput {
    width: 100%;
  }

  .level-visibility-control {
    grid-template-columns: 1fr;
  }

  .level-visibility-grid label {
    flex: 1 1 76px;
    justify-content: center;
  }

  .status-pill {
    right: 8px;
    bottom: 6px;
    max-width: calc(100vw - 68px);
    font-size: 10px;
  }

  .candle-countdown {
    right: 8px;
    bottom: 34px;
    font-size: 10px;
  }

  .level-badge {
    min-width: 34px;
    height: 17px;
    padding: 2px 4px;
    font-size: 11px;
  }

  .pane-label {
    left: 6px;
    font-size: 10px;
  }

  .signal-notice {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 62vh;
    border-left: none;
    border-top: 3px solid #009900;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.45);
    -webkit-overflow-scrolling: touch;
    transform: translateY(0);
    transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .signal-notice.signal-collapsed {
    display: block;
    transform: translateY(100%);
    pointer-events: none;
  }

  .signal-notice.signal-custom-position {
    position: absolute;
    right: auto;
    bottom: auto;
    width: min(360px, calc(100% - 16px));
    max-height: min(62vh, 520px);
    border-left: 5px solid #009900;
    border-top: 1px solid rgba(79, 255, 158, 0.2);
    border-radius: 8px;
    padding-bottom: 0;
    transform: none;
  }

  .signal-notice.signal-custom-position.signal-collapsed {
    display: none;
  }

  .signal-notice.signal-buy {
    border-top-color: #6aff00;
  }

  .signal-notice.signal-sell {
    border-top-color: #ff2d15;
  }

  .signal-head {
    flex-wrap: wrap;
  }

  .signal-actions {
    flex-wrap: wrap;
  }

  .copy-signal-button,
  .send-telegram-button,
  .hide-signal-button {
    height: 32px;
    padding: 0 10px;
  }

  .login-panel {
    width: min(360px, 100%);
    padding: 20px;
    gap: 14px;
  }

  .login-panel input,
  .create-user-form input,
  .create-user-form select {
    height: 44px;
    font-size: 16px;
  }

  .login-panel h1 {
    font-size: 26px;
  }

  .admin-panel {
    padding: 0;
  }

  .admin-dialog {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 0;
    border-radius: 0;
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .admin-user-list {
    -webkit-overflow-scrolling: touch;
  }

  .admin-device-list {
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 400px) {
  .symbol-title strong {
    font-size: 15px;
  }

  .coin-mark {
    width: 22px;
    height: 22px;
  }

  .account-name {
    display: none;
  }

  .timeframe-button,
  .icon-button {
    height: 34px;
    min-width: 34px;
    font-size: 12px;
  }

  .signal-filter-button,
  .add-toggle-button {
    min-width: 0;
    padding: 0 9px;
    font-size: 11px;
  }

  .pane-label {
    left: 6px;
    font-size: 9px;
  }

  .status-pill {
    font-size: 9px;
    max-width: calc(100vw - 56px);
  }

  .watermark strong {
    font-size: 32px;
  }

  .watermark::before,
  .watermark::after {
    font-size: 14px;
  }

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