  :root {
    --page: #ebebeb; --panel: #ffffff; --fg: #0f0f0f; --muted: #6a6d78; --line: #ebebeb; --hover: #f2f2f2;
    --active: #e3effd; --accent: #2962ff; --brand: #ff444f; --up: #089981; --down: #f23645;
    --pop-shadow: 0 2px 4px rgba(0,0,0,.1), 0 8px 24px rgba(0,0,0,.18);
    --font: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif;
  }
  body.dark {
    --page: #2e2e2e; --panel: #0f0f0f; --fg: #dbdbdb; --muted: #8c8c8c; --line: #2e2e2e; --hover: #2e2e2e;
    --active: #142e61; --pop-shadow: 0 2px 4px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.6);
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; background: var(--panel); color: var(--fg); font: 14px/1.3 var(--font); overflow: hidden; }
  button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
  svg { display: block; }

  /* ----- site header (Deriv-style bar, Tradion branding) */
  .site { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px 0 20px;
    background: var(--panel); border-bottom: 1px solid var(--line); }
  .brand { font: italic 800 26px/1 var(--font); color: var(--brand); letter-spacing: -0.5px; text-decoration: none; }
  .site-right { display: flex; align-items: center; gap: 10px; }
  .pill { height: 40px; padding: 0 18px; border-radius: 16px; background: var(--brand); color: #fff; font-weight: 600; }
  .pill:hover { background: #eb3e48; }
  .moon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
  .moon:hover { background: var(--hover); }

  /* ----- TradingView-like frame */
  .frame { position: absolute; top: 64px; left: 0; right: 0; bottom: 0; background: var(--page);
    display: grid; grid-template-columns: 52px 1fr; grid-template-rows: 38px 1fr 38px; gap: 4px 4px; padding-top: 0; }
  .bar { background: var(--panel); display: flex; align-items: center; min-width: 0; }
  .top { grid-column: 1 / 3; padding: 0 4px; gap: 2px; }
  .left { grid-row: 2 / 4; flex-direction: column; justify-content: flex-start; padding: 4px 0; gap: 1px; overflow: visible; }
  .center { position: relative; background: var(--panel); min-width: 0; min-height: 0; }
  .bottom { padding: 0 6px; gap: 2px; font-size: 13px; }
  #chart { position: absolute; inset: 0; }

  .tb { height: 34px; padding: 0 8px; border-radius: 4px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
  .tb:hover { background: var(--hover); }
  .tb.on { color: var(--accent); }
  .tb svg { width: 28px; height: 28px; }
  .tsep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; flex: none; }
  .grow { flex: 1; }
  .sym { font-weight: 700; padding-right: 10px; }
  .sym svg { width: 18px; height: 18px; }

  /* left drawing toolbar */
  .grp { position: relative; display: flex; align-items: center; }
  .tool { width: 38px; height: 34px; margin-left: 4px; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
  .tool svg { width: 28px; height: 28px; }
  .tool:hover { background: var(--hover); }
  .tool.on { background: var(--active); color: var(--accent); }
  .more { width: 10px; height: 34px; display: flex; align-items: center; justify-content: center; opacity: 0; border-radius: 2px; }
  .grp:hover .more { opacity: 1; }
  .more:hover { background: var(--hover); }
  .more svg { width: 6px; height: 10px; }
  .lsep { width: 32px; height: 1px; background: var(--line); margin: 5px 10px; }
  .lspacer { flex: 1; }

  .flyout { position: absolute; left: 50px; top: 0; z-index: 30; background: var(--panel); border-radius: 6px;
    box-shadow: var(--pop-shadow); padding: 6px 0; min-width: 230px; display: none; }
  .flyout.open { display: block; }
  .fhead { padding: 6px 16px 4px; font-size: 11px; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; }
  .fitem { width: 100%; height: 36px; display: flex; align-items: center; gap: 10px; padding: 0 16px 0 10px; text-align: left; }
  .fitem:hover { background: var(--hover); }
  .fitem.on { background: var(--active); color: var(--accent); }
  .fitem svg { width: 28px; height: 28px; flex: none; }

  /* legend */
  .legend { position: absolute; top: 6px; left: 8px; z-index: 3; display: flex; align-items: center; gap: 10px; font-size: 13px;
    pointer-events: none; padding: 2px 6px; border-radius: 4px; background: color-mix(in srgb, var(--panel) 55%, transparent); }
  .legend .title { font-size: 14px; }
  .legend .live { width: 8px; height: 8px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 25%, transparent); }
  .legend .live.off { background: #f7a600; box-shadow: none; }
  .legend .vals { display: flex; gap: 8px; }
  .legend .vals i { font-style: normal; }
  .up { color: var(--up); } .down { color: var(--down); }

  /* menus & dialogs */
  .menu { position: fixed; z-index: 40; background: var(--panel); border-radius: 6px; box-shadow: var(--pop-shadow); padding: 6px 0; min-width: 180px; display: none; }
  .menu.open { display: block; }
  .mitem { width: 100%; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 16px; text-align: left; }
  .mitem:hover { background: var(--hover); }
  .mitem.on { color: var(--accent); }
  .mitem svg { width: 28px; height: 28px; }
  .overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); display: none; align-items: flex-start; justify-content: center; padding-top: 8vh; }
  .overlay.open { display: flex; }
  .dialog { width: 680px; max-width: calc(100vw - 32px); max-height: 76vh; background: var(--panel); border-radius: 6px;
    box-shadow: var(--pop-shadow); display: flex; flex-direction: column; }
  .dhead { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 12px; font-size: 20px; font-weight: 700; }
  .x { width: 32px; height: 32px; border-radius: 4px; font-size: 18px; color: var(--muted); }
  .x:hover { background: var(--hover); }
  .search { margin: 0 20px 10px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 4px 0 10px; }
  .search input { flex: 1; border: 0; outline: 0; background: none; color: var(--fg); font: 16px var(--font); text-transform: uppercase; }
  .search input::placeholder { text-transform: none; color: var(--muted); }
  .chips { display: flex; gap: 6px; padding: 0 20px 10px; flex-wrap: wrap; }
  .chip { height: 30px; padding: 0 12px; border-radius: 16px; background: var(--hover); font-size: 13px; }
  .chip.on { background: var(--fg); color: var(--panel); }
  .dlist { overflow-y: auto; border-top: 1px solid var(--line); }
  .row { width: 100%; display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 12px; height: 42px; padding: 0 20px; text-align: left; border-bottom: 1px solid var(--line); }
  .row:hover { background: var(--hover); }
  .row .code { font-weight: 700; }
  .row .mk { color: var(--muted); font-size: 12px; text-transform: capitalize; }
  .irow { grid-template-columns: 1fr auto; }
  .irow .tick { color: var(--accent); font-weight: 700; }

  .toggle { height: 26px; padding: 0 7px; border-radius: 4px; }
  .toggle:hover { background: var(--hover); }
  .toggle.on { color: var(--accent); }
  .clock { padding: 0 8px; white-space: nowrap; }
  .toast { position: fixed; bottom: 56px; left: 50%; transform: translateX(-50%); z-index: 60; background: #0f0f0f; color: #fff;
    padding: 9px 16px; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none; font-size: 13px; }
  .toast.show { opacity: .92; }
  @media (max-width: 720px) { .hide-sm { display: none !important; } .pill { padding: 0 12px; } }

  /* ----- alerts panel (slides in from the right, under the header) */
  .badge { display: inline-block; min-width: 18px; height: 18px; line-height: 18px; margin-left: 4px; padding: 0 5px; border-radius: 9px;
    background: #fff; color: var(--brand); font-size: 11px; font-weight: 700; }
  .apanel { position: fixed; z-index: 45; top: 64px; right: 0; bottom: 0; width: 360px; max-width: 100vw; background: var(--panel);
    border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0,0,0,.08); display: flex; flex-direction: column;
    transform: translateX(105%); transition: transform .2s ease; font-size: 13px; }
  .apanel.open { transform: none; }
  .apanel-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 12px; height: 46px; border-bottom: 1px solid var(--line); }
  .ptabs { display: flex; gap: 4px; height: 100%; }
  .ptabs button { height: 100%; padding: 0 10px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
  .ptabs button.on { color: var(--fg); border-bottom-color: var(--brand); }
  .reddot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); margin-left: 3px; vertical-align: 2px; }
  .apanel-body { padding: 14px; overflow-y: auto; flex: 1; }
  .pform { display: flex; flex-direction: column; gap: 8px; }
  .prow { display: flex; gap: 8px; }
  .prow > input { flex: 1; min-width: 0; }
  .plabel { font-weight: 600; margin-top: 2px; }
  .apanel input, .apanel select { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
    color: var(--fg); font: 14px var(--font); outline: none; }
  body:not(.dark) .apanel input, body:not(.dark) .apanel select { border-color: #d6d6d6; }
  .apanel input:focus, .apanel select:focus { border-color: var(--accent); }
  .primary { height: 38px; padding: 0 16px; border-radius: 6px; background: var(--brand); color: #fff; font-weight: 600; }
  .primary:hover { background: #eb3e48; }
  .primary:disabled, .sbtn:disabled { opacity: .6; cursor: default; }
  .sbtn { height: 28px; padding: 0 9px; border-radius: 6px; border: 1px solid #d6d6d6; font-size: 12px; font-weight: 600; white-space: nowrap; }
  body.dark .sbtn { border-color: #3a3a3a; }
  .sbtn.big { height: 36px; padding: 0 12px; font-size: 13px; }
  .sbtn:hover { background: var(--hover); }
  .sbtn.del:hover { color: var(--down); border-color: var(--down); }
  .muted { color: var(--muted); } .small { font-size: 12px; margin: 0; }
  .err { color: var(--down); } .ok { color: var(--up); }
  .link { color: var(--muted); text-decoration: underline; font-size: 12px; padding: 0; }
  .phead { margin: 18px 0 4px; font-size: 11px; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; }
  .alist { list-style: none; margin: 0; padding: 0; }
  .al { display: flex; gap: 8px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .al-main { flex: 1; min-width: 0; }
  .al-price { font-weight: 700; font-variant-numeric: tabular-nums; }
  .al-price .muted { font-weight: 400; }
  .al-note { word-break: break-word; }
  .al-status { font-size: 12px; color: var(--muted); }
  .al-act { display: flex; gap: 4px; }
  .al.hit .al-price, .al.paused .al-price { opacity: .55; }
  .dir { font-size: 11px; line-height: 19px; } .dir.up { color: var(--up); } .dir.down { color: var(--down); }
  .pfoot { display: flex; justify-content: space-between; margin-top: 16px; }
  .banner { width: 100%; text-align: left; margin-bottom: 12px; padding: 10px 12px; border-radius: 6px; border: 1px solid #ffad3a;
    background: rgba(255,173,58,.12); font-size: 13px; }
  .steps { margin: 0 0 6px; padding-left: 18px; color: var(--muted); line-height: 1.45; }
  .steps li { margin-bottom: 4px; } .steps b, .steps code { color: var(--fg); }
  body.picking #chart { cursor: crosshair; }
  .pick-hint { display: none; position: absolute; z-index: 6; top: 40px; left: 50%; transform: translateX(-50%); padding: 7px 14px;
    border-radius: 6px; background: #ff9800; color: #000; font-weight: 600; font-size: 13px; pointer-events: none; white-space: nowrap; }
  @media (max-width: 720px) { .apanel { width: 100vw; } }
